Skip to content

Tag: pandas

Processing multiple modes in pandas

I’m obviously dealing with slightly more complex and realistic data, but to showcase my trouble, let’s assume we have these data: I want to find modal values of purchases by date: agg_mode will show that for user_id 100 we have two modal values: [cookies, jam]. This is totally fine with me, when i…

Python pandas group non repeating values

Hi I have a data frame which looks like this I would like to groupby and sum for non repeating values in col1 for e.g. Is there any way I can do this via pandas functions? Answer IIUC, you could create groups using groupby + cumcount (where the nth occurrences of each col1 value will be grouped the same); the…