【发布时间】:2020-09-29 04:13:18
【问题描述】:
我正在清理表单的调查结果。
在名为“您最信任哪个来源以获取有关政治的见解?”的列下所有包含字符串/子字符串“news”的行条目的条目都应替换为字符串“newspapers or news apps”
这里,“responses”是调查回复的 csv 文件的名称。
if responses['Which source do you trust the most to get insights on politics?'].str.contains('news') == True:
responses['Which source do you trust the most to get insights on politics?'] = 'newspapers or news apps'
我收到以下代码错误:
ValueError:Series 的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。
请帮忙!任何线索表示赞赏:)
【问题讨论】:
标签: pandas dataframe data-cleaning