-1

I have a dataset with data from 2015 and 2016 for different buildings, their location information. Like this:enter image description here

enter image description here

As we can see, for the same OSEBuildingID most of their information are available and are the same, however, there are NaN in some columns. So we can use the value of the same BuildingId to fillin those values. I've tried:

df.groupby('OSEBuildingID')['LargestPropertyUseTypeGFA'].transform(lambda group: group.fillna(group.mode()))

But nothing has changed, could anyone help please?

Thank you very much

Samir Hinojosa
  • 825
  • 7
  • 24
Shyan
  • 7
  • 2

1 Answers1

-1

Try:

df_plus1['LargestPropertyUseTypeGFA']=df_plus1.groupby('OSEBuildingID')['LargestPropertyUseTypeGFA'].apply(lambda x: x.ffill().bfill())
Hamza usman ghani
  • 2,264
  • 5
  • 19
Shyan
  • 7
  • 2