创建数据集
dataDict = {'a':['one','two'], 'b':[[2,3],[1,3,6]], 'c':[1,2]}
dataDf = pd.DataFrame(dataDict)
实现行转列,drop(‘level_2’, axis = 1):删掉新产生的索引,level_i中的i为groupby中列数
df = t.groupby(['a', 'c']).b.apply(lambda x: pd.DataFrame(x.values[0])).reset_index().drop('level_2', axis = 1)
df.columns = ['a','c','b']
python多列合并成为一行,针对b列
df['d'] = df['b'].astype(str) + ','
df.groupby(['a','c']).d.sum().reset_index()