【发布时间】:2022-01-20 12:18:24
【问题描述】:
我在 pandas 数据框中有一列,其中有时有一个重复的字符串:
| col1 | col2 |
|---|---|
| 1 | hello |
| 2 | bye |
| 3 | hello |
| 4 | morning |
| 5 | night |
| 6 | hello |
我想做的是修改“hello again”中除第一次出现的“hello”之外的所有内容。所以第一次出现的 hello 保持不变。
| col1 | col2 |
|---|---|
| 1 | hello |
| 2 | bye |
| 3 | hello again |
| 4 | morning |
| 5 | night |
| 6 | hello again |
【问题讨论】:
-
很高兴看到你的思路
标签: python python-3.x pandas dataframe