【问题标题】:Drop Columns in Data based on Condition根据条件删除数据中的列
【发布时间】:2019-11-13 13:26:46
【问题描述】:

我有一个 1 行 33 列的数据框。 我想删除找到 0 到 30 之间的数字以及 nan 值的列。

有没有有效的方法来做到这一点?

【问题讨论】:

标签: python python-3.7


【解决方案1】:

只是想尝试一下:

filtered = df.loc[:, ~((df.isnull()) | (df.sum(axis=0)<=30) & (df.sum(axis=0)>=0)).iloc[0]]

【讨论】:

  • 请解释你的答案。它已被标记为低质量,如果不改进可能会被删除。
猜你喜欢
  • 1970-01-01
  • 2016-04-26
  • 1970-01-01
  • 2022-01-20
  • 1970-01-01
  • 1970-01-01
  • 2017-05-09
  • 1970-01-01
  • 2021-12-14
相关资源
最近更新 更多