提问人:KappamanOosh 提问时间:12/8/2020 最后编辑:KappamanOosh 更新时间:12/8/2020 访问量:39
数据帧将行中的值转换为唯一列
Dataframe convert Values in row into a unique column
问:
我有一个名为分类列,它显示了不同类型的犯罪结果,即:outcome category
{Investigation complete; no suspect identified, Local resolution, Unable to prosecute suspect, Awaiting court outcome, Formal action is not in the public interest, Offender given penalty notice, Under investigation}
\
从列中,我想提取其中值 =Awaiting court outcome, Under investigation
并在列中出现这些值时创建一个新列,表示 true 或 falseArrests
outcome
谢谢
答: 暂无答案
评论
outcome category
type(df.iloc[0, 'outcome category'])
df['outcome'] = df['outcome category'].apply(lambda x : 'Awaiting court outcome' in x or 'Under investigation' in x)