更新时间:2023-01-30 19:55:53
尝试:
df['float'] = df['strCondition'].str.extract(r'(\d+.\d+)').astype('float')
输出:
DATE strCondition float
0 4/3/2018 2.9 2.9
1 4/3/2018 3.1, text 3.1
2 4/3/2018 2.6 text 2.6
3 4/3/2018 text, 2.7 2.7