How to merge or group dataframe?
I have a dataframe likes
City Age column1 column2
0 Texas 20 7 5
1 Texas 35 8 1
2 Texas 30 8 2
I want to merge the column City with same city into 1 row and centralized, other columns are unchanged. So the output like
City Age column1 column2
0 20 7 5
1 Texas 35 8 1
2 30 8 2
开发者_运维百科Is it posible to do it with dataframe on pandas. The final target is that I want to save the dataframe to csv file likes
use pd.merge(df1,df2, how="choose one from inner,left,right, full joins", onleft = "df1 column name " ,onright = "df2 column name " )
精彩评论