试图使列的值为1和2(真,假)出不好的列!发现了一个手动劳动的方式检查和插补值一个接一个,并检查他们通过包含模块,但我想循环超过他们!
我的数据
`df['activities']
`
0 Game | jogging | self teaching
1 Game | outside food | junk food | with GF | self teaching
2 Game | outside food | jogging | self teaching
3 outside food | fab | with GF | self teaching
4 eating in restaurant | drinking | Game | outside food | with GF | jogging | self teaching
字符串
唯一的好办法就是大量的劳动!
`df["Working out"]=df["activities"].str.contains("jogging |indoor workout |gym ")
型
“我打扫了一下,分开了,试着把错误的答案翻过来;
df["activities"]=df["activities"].str.replace("|","",regex=True)
df["activities"]=df["activities"].str.split(" ")
activities=[]
for act in df["activities"]:
if act not in activities:
activities.append(act)
型
1条答案
按热度按时间cigdeys31#
字符串
的数据