【发布时间】:2021-10-06 14:01:00
【问题描述】:
我有这样的数据:
draft_round
0 1st round
1 3rd round
2 1st round
3 16th round
4 2nd round
... ...
4680 1st round
4681 NaN
4682 2nd round
4683 2nd round
4684 1947 BAA Draf
如您所见,每一行数据都有复杂的数据,是单词和数字的组合。对我来说重要的是得到这些行中的数字。例如,我想在名为“第 1 轮”的数据行中获取数字“1”,在“第 16 轮”数据行中获取“16”。换句话说,我希望产量如下:
draft_round
0 1
1 3
2 1
3 16
4 2
... ...
4680 1
4681 NaN
4682 2
4683 20
4684 1947 BAA Draf
我希望我能够解释我的问题,提前谢谢。
【问题讨论】:
-
你也可以使用re库中的sub
标签: python python-3.x pandas dataframe data-science