'ValueError: Length mismatch: Expected axis has X elements, new values have Y elements
I try to fill missing value with the most appeared one in its group . Code :
f = lambda x: x.mode().iat[0] if x.notna().any() else np.nan
s = df.groupby('VehicleType')['FuelType'].transform(f)
df['FuelType']=df['FuelType'].fillna(s)
Error: ValueError: Length mismatch: Expected axis has 316879 elements, new values have 354369 elements
Possible solutions: I think that maybe the VehicleType data has missing values, therefore it gives an error .Because when I use another column that has no missing values, it works. But I have to use VehicleType for this task .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

