简体   繁体   English

删除 pandas dataframe 的所有行,其中所有列都满足某些条件

[英]Delete all rows of a pandas dataframe where certain conditions are met over all columns

My dataframe looks like this:我的 dataframe 看起来像这样:

I want to delete ALL rows (red marked in the picture) where every column has a value like:我想删除所有行(图中红色标记),其中每列的值如下:

"", "nan", "NaT"

I tried several things like dropna, replacing and dropping, but I am can not make it work to delete it.我尝试了几种方法,例如 dropna、replace 和 drop,但我无法删除它。

Use:利用:

mask = df.fillna('').isin(["", "nan", "NaT"])

df = df[~mask.all(axis=1)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果满足某些条件,则将行转换为熊猫数据框的列 - Turn rows into columns for pandas dataframe if certain conditions are met Pandas:如何删除需要满足2个不同列中2个条件的行 - Pandas: How to delete rows where 2 conditions in 2 different columns need to be met 通过查询选择所有列均满足条件的位置 - Selecting with query where conditions are met for all columns 如果在组内不满足任何条件,如何 select 所有行,如果在 pandas 中满足组内的某些条件,如何 select 行的子集 - How to select all rows if no conditions are met within a group and select a subset of rows if certain conditions within a group are met in pandas 如果所有列都包含特定模式,请在pandas数据框中选择行 - Select rows in pandas dataframe if all the columns contain certain pattern 删除Pandas数据帧行,其中所有列的总和等于0 - Delete Pandas dataframe row, where the sum of all columns equals to 0 Pandas dataframe 凝胶一组列等于零的所有行 - Pandas dataframe gel all rows where a set of columns are equal to zero Pandas Dataframe 查找所有列相等的行 - Pandas Dataframe Find Rows Where all Columns Equal 使用 iLoc 检查 dataframe 中的所有行是否满足特定条件 - Checking that ALL rows have met a certain criteria in a dataframe using iLoc 删除熊猫中某些条件以下的所有行 - Delete all rows bellow a certain condition in pandas
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM