I have a CSV file that looks like this:
|innings | bowler |
|--------|---------------|
|1 | P Kumar |
|1 | P Kumar |
|1 | P Kumar |
|1 | P Kumar |
|1 | Z Khan |
|1 | Z Khan |
|1 | Z Khan |
|2 | AB Dinda |
|2 | AB Dinda |
|2 | I Sharma |
Desired Output
|innings | bowler |
|--------|----------------------|
|1 | P Kumar,Z Khan |
|2 | AB Dinda,I Sharma |
Code I Applied:
df.groupby(['innings']).bowler.sum().drop_duplicates(subset="bowler",keep='first',inplace=True)
but for some reason, it is giving me an error TypeError: drop_duplicates() got an unexpected keyword argument 'subset'
then i tried without subset: drop_duplicates("bowler",keep='first', inplace=True) now i am getting this error TypeError: drop_duplicates() got multiple values for argument 'keep'
Use
DataFrame.drop_duplicates
first by both columns and then aggregatejoin
: