[Pandas]:基于相同列值合并Dataframe的行

13 浏览
0 Comments

[Pandas]:基于相同列值合并Dataframe的行

我有一个如下所示的数据框 -

enter image description here

如何将行合并,使得属于同一个邮政编码的所有街区在同一行显示,用逗号隔开。类似于这样 -

| 邮政编码 | 区 | 街区 |

| M1B | Scarborough | Rouge, Malvern |

| M5A | Downtown Toronto | Harbourfront, Regent Park |

| M6A | North York | Lawrence Heights, Lawrence Manor |

其余行保持不变...

0