Answers for "pandas merge with group of columns"

0

pandas group by concat

In [124]:

df.groupby(['name','month'])['text'].apply(lambda x: ','.join(x)).reset_index()

Out[124]:
    name  month         text
0  name1     11       hej,du
1  name1     12        aj,oj
2  name2     11     fin,katt
3  name2     12  mycket,lite
Posted by: Guest on January-15-2021
12

dataframe groupby multiple columns

grouped_multiple = df.groupby(['Team', 'Pos']).agg({'Age': ['mean', 'min', 'max']})
grouped_multiple.columns = ['age_mean', 'age_min', 'age_max']
grouped_multiple = grouped_multiple.reset_index()
print(grouped_multiple)
Posted by: Guest on October-15-2020

Code answers related to "pandas merge with group of columns"

Python Answers by Framework

Browse Popular Code Answers by Language