Skip to content

Instantly share code, notes, and snippets.

@hute37
Forked from aniruddha27/GroupBy_transform.py
Created June 15, 2020 09:09
Show Gist options
  • Save hute37/3a533d1cc99537903a793eaac42beb02 to your computer and use it in GitHub Desktop.
Save hute37/3a533d1cc99537903a793eaac42beb02 to your computer and use it in GitHub Desktop.
df['Item_Weight'] = df.groupby(['Item_Fat_Content','Item_Type'])['Item_Weight'].transform(lambda x: x.fillna(x.mean()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment