原表数据: 最后4行合并为1行: def ab(df): return\',\'.join(df.values) df = df.groupby([\'股票代码\',\'股票简称\'])[\'所属概念\'].apply(ab) df = df.reset_index() 效果如下: 相关文章: