【发布时间】:2019-08-09 15:24:19
【问题描述】:
数据框如下所示
col_a
Python PY is a general purpose PY language
Programming PY language in Python PY
Its easier to understand PY
The syntax of the language is clean PY
此代码我已尝试实现此功能,但无法获得预期的输出。如果有任何帮助表示赞赏。
这是我使用正则表达式处理的以下代码:
df['col_a'].str.extract(r"([a-zA-Z'-]+\s+PY)\b")
期望的输出:
col_a col_b_PY
Python PY is a general purpose language Python PY purpose PY
Programming PY language in Python PY Python PY Programming PY
Its easier to understand PY understand PY
The syntax of the language is clean PY clean PY
【问题讨论】: