简体   繁体   English

如何根据特定列中的空值从数据框中删除行?

[英]How to drop rows from a dataframe as per null values in a specific column?

How to drop rows from a dataframe as per null values in a specific column? 如何根据特定列中的空值从数据框中删除行?

Say I have a dataframe that has three columns a,b,c and all can have null values, but I only want to droprows where column b has null/NaN. 假设我有一个包含三列a,b,c的数据框,并且所有列都可以为空值,但是我只想对b列具有null / NaN的地方进行下拉。 How can I do that in pandas dataframe? 如何在熊猫数据框中执行此操作?

这应该可以解决问题:

df = df.dropna(subset=['b'], axis=1)

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

相关问题 如何通过列值的条件删除 DataFrame 中的行 - How to Drop rows in DataFrame by conditions on column values 如果特定列包含 null 值,如何从 dataframe 中删除行? - How to delete rows from a dataframe if specific columns contains null values? 如何从数据框中删除具有空值和分类变量的行? - How can I drop the rows with null values and categorical variables from the dataframe? 如何删除带有条件的 Pandas DataFrame 行以保留特定列值 - How to drop Pandas DataFrame rows with condition to keep specific column value 从具有特定单词的列中删除包含 null 值的行 [Python] - drop the rows that contain the null values from columns with a specific word [Python] 有没有办法通过将列值与列表中的值进行比较来从 dataframe 中删除行? - Is there a way to drop rows from a dataframe by comparing a column value to values in list? 从 dataframe 中删除值在整列中仅出现一次的行 - Drop rows from dataframe with the values occuring only once in the whole column 如何从数据框中删除所有列值为零或布尔值为false的行 - How to drop the rows from dataframe that have all column values as zero or boolean false 如何使用列中的特定值删除或删除行到 dataframe 中? - How to delete or drop lines into a dataframe using specific values in a column? 按列值删除 Pandas DataFrame 中的行(文本) - Drop rows in Pandas DataFrame by Column values (text)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM