首页 > 解决方案 > 从python中的文本数据中提取数字和相邻单词

问题描述

我在一列数据框中有文本字符串数据

Text Column
The doctor has advised the patient to pay $200 for the treatment
Patient submitted the $200 operation fee but not the admit fee  $100

从上面,如何提取数字以及该数字前后的单词并将它们存储在单独的变量中

Expected Results
Var1                 Var2     
pay $200 for
the $200 operation   fee $100

标签: pythonregexdata-extraction

解决方案


([a-zA-Z]+) *?\$?([0-9]+) ?([a-zA-Z]*)

上网试试


推荐阅读