有没有一种技术可以使用groupby将列聚合到另一个单元格

时间:2020-05-07 23:42:01

标签: python pandas-groupby aggregation

我有一个多索引表,我想做一个groupby来将列汇总到一个新列中。 该表的示例是:

City       State       Clubs
New York    NY     Giants, Jets
New York    NY     Jets, Knicks
New York    NY     NYFC
Houston     TX     Astros, Rockets
Houston     TX     Rockets
San Antonio TX     Spurs
San Antonio TX     Scorpions

我要获取的表是:

City      State     Clubs
New York    NY      Giants, Jets, Knicks
Houston     TX      Astros, Rockets
San Antonio TX      Scorpions, Spurs

我该怎么办?

0 个答案:

没有答案