hello,
I’m trying to groupby a dataframe without aggregation. I’ve found some solutions, but I’m getting some weird outputs.
import pandas as pd
df = pd.DataFrame( {'key': ['A', 'B', 'A', 'B'], 'value': [2,2,1,1]})
print(df)
print(df.groupby('key').nth[:]) # only this one works
print(df.groupby('key').head()) # doesn't work
print(df.groupby('key').filter(lambda x:True)) # doesn't work
print(df.groupby('key').apply(lambda x:x)) # doesn't work
In cases where it doesn’t work, it does not throw error, it just prints the original df dataframe. Any suggestions why?
p.s. the dataframe example and one of the solutions is picked from StackOverflow, but the other guy also commented that he was unable to reproduce the suggested…