What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-05 11:39:11
def conditional_impute(input_df, choice='median')
def conditional_impute(input_df, choice='median'): new_df = input_df.copy() if choice == 'median': new_df['Age'] = round(new_df.groupby(['Sex', 'Pclass'])['Age'].transform(func = lambda x: x.fillna(x.median())),1) elif ch... Add solution -
Python 2021-10-29 07:47:08
df groupby loop
grouped = df.groupby('A') for name, group in grouped: ... Add solution -
-
Python 2021-10-23 14:25:06
add a new categorical column to an existing table python
d = df.groupby('Item_Identifier')['Sales'].mean().to_dict() print (d) {'Beef': 3030.0, 'Milk': 1233.3333333333333, 'Tea': 150.0} print (df['Item_Identifier'].map(d)) 0 1233.333333 1 1233.333333 2 1233.333333 3 3030.000000 4 3030.000000 5 ... Add solution
Best helpers
Ranking is empty