Python Pandas: How to groupby and count and select a portion of counts? -


i have df this:

          new_org               old_org    asn  cc 0    85736 pcizzi   85736 - pcizzi s .a  23201  py 1             001              001 host  40244  2      85736 blah       85736 - whatevs  23201  py 3             001        001 complex  55734  in 4  001 hospedagem   001 hospedagem ltda  36351  5          001web  action.us.001web.net  36351  

and groupby df based on 'asn' column , select groups have more 1 row. how doing not sure if correct:

df.groupby('asn').apply(lambda x:x.count()>1) 

can help?

you can filter group.

try df.groupby('asn').filter(lambda x: len(x) > 1) return dataframe. group again further if necessary.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -