简体   繁体   English

从列值为 NaN 的所有列中删除行

[英]Remove rows from all the columns where column value is NaN

I have small dataframe with null values in columns.我在列中有小 dataframe 和 null 值。 👉 Link for the data set link 👉 数据集链接的链接

I can remove rows with null values for one column at a time with this command - df.drop(df[df['duration'].isnull() ].index) But, suppose I had a large dataframe with hundreds of columns with null row values, then removing null row values for one column at a time is not possible.我可以使用此命令一次删除一列的 null 值的行 - df.drop(df[df['duration'].isnull() ].index)但是,假设我有一个大的 dataframe 与数百列null 行值,然后一次删除一列的 null 行值是不可能的。 What should be my approach is such case.我的方法应该是这种情况。 Please explaing with above data set.请用上述数据集进行解释。

As @Omniswitcher commented, df.drop() will work.正如@Omniswitcher 评论的那样, df.drop()将起作用。

pd.read_excel('Movie.xlsx').dropna(axis=0)

Output: Output: 在此处输入图像描述

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

相关问题 Pandas 删除几列不是nan的行 - Pandas remove rows where several columns are not nan 从值不是 NaN 的多个列创建新列 - Create new column from multiple columns where value that is not NaN Python/Pandas - 从数据框中删除所有列,其中 > 50% 的行的值为 0 - Python/Pandas - Remove all columns from dataframe where > 50% of rows have the value 0 如何遍历某些列和所有行,如果值为 nan,则用其他列的值填充该值? - How can I loop though some columns and all rows, and if the value is nan, fill that value with values of other column? 删除列仅包含 NaN 或零的行 - remove rows where columns contain only NaN or Zero Pandas:当列中的所有数据都是NaN时,从多级索引中删除索引条目(及其所有行) - Pandas: Remove index entry (and all it's rows) from multilevel index when all data in a column is NaN 如何删除另一列中具有特定值的所有 NaN 值的行? - How to remove rows that have all NaN values for a specific value in another column? 从pandas数据框中选择行,其中指定的列都不都是NaN - Select rows from pandas data frame where specified columns are not all NaN 如何从数据框中删除多索引级别等于NaN(无值)的列 - How to remove columns where Multiindex levels equal NaN (no value) from a dataframe 如何删除除日期列之外的所有行都是 NaN 的地方? - How to dropna where all rows are NaN except the date column?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM