【发布时间】:2020-10-25 19:16:12
【问题描述】:
我一直在 Python 中使用 Pandas 的 Crop 命令来删除行和列。我正在尝试预测 covid-19 在哥伦比亚的行为。现在,我需要在 Country_Region 列中删除所有包含哥伦比亚以外国家的行,您能帮帮我吗?
数据(.csv):https://drive.google.com/file/d/1eEZfBmMQTlJjx1PSmC3bamukqhxR_oAy/view?usp=sharing
【问题讨论】:
-
在一天结束时,您想拥有哥伦比亚的所有行 - 对吧?顺便说一句:您能否将您的数据集提供给公众查看?
-
谢谢!数据集可用
-
columbia_df = df[df['Country_Region'] == 'Columbia']有效吗?这将过滤到Country_Region列等于“Columbia”的行 -
是的,它的工作,谢谢。但现在不会删除我不需要的列:(
-
您可以将结果写入新的 csv(或数据库、变量等)。
标签: python-3.x pandas csv