Open talegari opened 4 years ago
Can you provide some motivation for this? Why doesn't passing callables to agg / transform / apply suffice?
Tom,
Thanks for picking this up.
I started with writing dplyr like operations on pandas dataframes with the primary intent of letting the user not worry about the indexes (see is_tidy_frame
). For example, mutate
will work on both grouped and ungrouped dataframes via the right accessor.
Having the groupby accessor will avoid two things:
def mutate(df, func_list, check = True):
if check:
assert is_tidy_frame(df)
if is_grouped_frame(df):
groupvars = group_vars(df)
for func in func_list:
df = df.apply(func)
df = df.reset_index(drop = True).pipe(group_by, groupvars)
else:
for func in func_list:
df = df.pipe(func)
return(df)
Thanks for providing the option to create custom accessors via pandas.api.extensions. This is prefereable method to extend pandas dataframes over inheritance/sub-classing. Currently, this supports these: dataframe, series, index.
Please extend this support for groupBy objects.