import pandas as pd
#Reproduce the dataframe
l = ["name : john",
"address : Milton Kings",
"phone : 43133241",
"Concern : customer complaint about the services is so suck" ]
df = pd.DataFrame(l)
#split on each element of the dataframe, and keep the second part
df.applymap(lambda x: x.split(":")[1])
输入:
^{pr2}$
输出:
0
0 john
1 Milton Kings
2 43133241
3 customer complaint about the services is so suck
假设你想保留句子的第二部分,你可以使用applymap 解决问题的方法。在
输入:
^{pr2}$输出:
您可以做的一件事是将“:”后的句子与数据框分开。你可以通过从你的数据帧中创建一个序列来实现这一点。在
假设c是你的系列。在
这样你就能把你的句子和冒号分开。在
相关问题 更多 >
编程相关推荐