【发布时间】:2016-03-03 07:13:50
【问题描述】:
我查看了数据框列中的唯一值 - 我拥有的 pandas。在我不想包含的列之一中有一些名称,如何从数据框中删除这些行,而不使用索引值表示法,而是说 if row value = "this" then remove
喜欢...
new = df.copy
df['some column'].drop_values('this','that','other')
【问题讨论】:
我查看了数据框列中的唯一值 - 我拥有的 pandas。在我不想包含的列之一中有一些名称,如何从数据框中删除这些行,而不使用索引值表示法,而是说 if row value = "this" then remove
喜欢...
new = df.copy
df['some column'].drop_values('this','that','other')
【问题讨论】:
参见indexing with isin(另请参阅boolean indexing):
mask = df['some column'].isin(['this', 'that', 'other'])
df[~mask]
【讨论】: