【发布时间】:2023-03-26 10:40:01
【问题描述】:
我有一个相当大的 pandas 数据框(超过 100 万行),其中的列包含字符串或数字。现在我想在“应用”表达式之前将字符串拆分为一列。
一个例子来解释我的意思:
我有什么:
a b description
2 4 method A is applied
10 5 titration is applied
3 1 computation is applied
我在寻找什么:
a b description
2 4 method A
10 5 titration
3 1 computation
我尝试了以下,
df.description = df.description.str.split('is applied')[0]
但这并没有带来预期的结果。
任何想法如何做到这一点? :-)
【问题讨论】:
标签: python-3.x pandas dataframe split