【发布时间】:2020-08-30 10:29:10
【问题描述】:
我想将所有仅包含 df['Comments'][2] 等表情符号的行更改为 N/A。
df['Comments'][:6]
0 nice
1 Insane3
2 ????????❤️
3 @bertelsen1986
4 20 or 30 mm rise on the Renthal Fatbar?
5 Luckily I have one to ????????????
以下代码没有返回我期望的输出:
df['Comments'].replace(';', ':', '!', '*', np.NaN)
预期输出:
df['Comments'][:6]
0 nice
1 Insane3
2 nan
3 @bertelsen1986
4 20 or 30 mm rise on the Renthal Fatbar?
5 Luckily I have one to ????????????
【问题讨论】:
-
你不想替换最后一行的
????????????? -
如果可以保留它们,我想保留它们。但是如果代码太复杂,去掉也可以。
标签: python python-3.x regex pandas special-characters