I have dataframe as below
Wash_Month Wash_Day
0 3 2
1 4 3
And the expected out put is
#d={'Wash_Month':'Wash_Month/Wash_Day','Wash_Day':'Wash_Month/Wash_Day'}
#df.T.astype(str).groupby(d).agg(','.join)
Out[329]:
0 1
Wash_Month/Wash_Day 3,2 4,3
As you saw , I first do the transpose T
.
If we groupby
with axis=1
and remove the T
, I expected the same out put.
df.astype(str).groupby(d,axis=1).agg(','.join)
Out[330]:
Wash_Month/Wash_Day
0 Wash_Month,Wash_Day
1 Wash_Month,Wash_Day
The out put is mismatched with expected output . Is there specific problem onagg
with join
with groupby
of axis=1
Since other agg
function like sum
work as normal
df.astype(str).groupby({'Wash_Month':'Wash_Month/Wash_Day','Wash_Day':'Wash_Month/Wash_Day'}, axis=1).sum()
Out[332]:
Wash_Month/Wash_Day
0 32.0 # str 3 + str 2
1 43.0
About why the result become float rather than a str check link
Appreciate your help :-)