Answers for "pandas drop rows if a column is nan"

1

drop rows that contain null values in a pandas dataframe

df.dropna(inplace=True)
# to drop any rows that contain any null values
df.dropna(how='all', inplace=True)
# to drop the rows wich all of it's values is any

# if you want to drop the columns not the rows you just set the axis to 1 like this:
df.dropna(axis=1, inplace=True)
Posted by: Guest on December-09-2021
5

dropping nan in pandas dataframe

df.dropna(subset=['name', 'born'])
Posted by: Guest on April-27-2020

Code answers related to "pandas drop rows if a column is nan"

Python Answers by Framework

Browse Popular Code Answers by Language