Skip to content

Commit

Permalink
Fix bug with non-numerical columns in util.aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
rantahar committed Dec 5, 2023
1 parent 3751ba0 commit cb7b382
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions niimpy/preprocessing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ def aggregate(df, freq, method_numerical='mean', method_categorical='first', gro
assert method_numerical in ['mean', 'sum', 'median'], \
'Cannot recognize sampling method. Possible values: "mean", "sum", "median".'
if method_numerical == 'sum':
sub_df1 = groupby.resample(freq, **resample_kwargs).sum()
sub_df1 = groupby.resample(freq, **resample_kwargs).sum(numeric_only=True)
elif method_numerical == 'mean':
sub_df1 = groupby.resample(freq, **resample_kwargs).mean()
sub_df1 = groupby.resample(freq, **resample_kwargs).mean(numeric_only=True)
elif method_numerical == 'median':
sub_df1 = groupby.resample(freq, **resample_kwargs).median()
sub_df1 = groupby.resample(freq, **resample_kwargs).median(numeric_only=True)
else:
print("Can't recognize sampling method")

Expand Down

0 comments on commit cb7b382

Please sign in to comment.