516b77610d058cfe3a6f379e8ff9753065d48707,janitor/functions.py,,groupby_agg,#Any#Any#Any#Any#Any#,3208
Before Change
:returns: A pandas DataFrame.
new_col = df.groupby(by)[agg_column_name].transform(agg)
df_new = df.assign(**{new_column_name: new_col})
return df_new
@pf.register_dataframe_accessor("data_description")
After Change
// replace the values with some outrageous value, that should not exist
// in the column. Also, the hasnans property is significantly faster than
// .isnull().any()
if any(df[col].hasnans for col in by):
mapping = {
column: ".*^%s1ho1go1logoban?*&-|/\\gos1he()//_" for column in by
}
df[new_column_name] = (
df.fillna(mapping).groupby(by)[agg_column_name].transform(agg)
)
else:
df[new_column_name] = df.groupby(by)[agg_column_name].transform(agg)
return df
@pf.register_dataframe_accessor("data_description")
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: ericmjl/pyjanitor
Commit Name: 516b77610d058cfe3a6f379e8ff9753065d48707
Time: 2020-08-09
Author: samueloranyeli@gmail.com
File Name: janitor/functions.py
Class Name:
Method Name: groupby_agg
Project Name: ContextLab/hypertools
Commit Name: 2df451029d31850d7f5353b3786b875f17f740a5
Time: 2018-04-06
Author: andrew.heusser@gmail.com
File Name: hypertools/tools/load.py
Class Name:
Method Name: load
Project Name: quiltdata/quilt
Commit Name: 7d9a7fead18653a43645c3d673499cf639337406
Time: 2020-06-03
Author: akarve@users.noreply.github.com
File Name: lambdas/es/indexer/index.py
Class Name:
Method Name: handler