man*_*mar 2 python dataframe python-3.x pandas
如何删除'/'和'/'值之后,即25?
样本:
score
10
24
19
20/25
18/25
16/25
Run Code Online (Sandbox Code Playgroud)
输出:
score
10
24
19
20
18
16
Run Code Online (Sandbox Code Playgroud)
你可以在这里使用df.replace函数。
df['score'] = df['score'].replace('/.*','',regex=True)
Run Code Online (Sandbox Code Playgroud)
df 会变成这样:
score
0 10
1 24
2 19
3 20
4 18
5 16
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
66 次 |
| 最近记录: |