You can remove NaN values from a Pandas DataFrame using the dropna method:
df = df.dropna()
df.dropna() returns a new DataFrame with all rows containing at least one NaN value removed.
You can also remove NaN values from a specific column:
df = df.dropna(subset=["column_name"])
df.dropna(subset=[“column_name”]) returns a new DataFrame with all rows containing at least one NaN value in the “column_name” column removed.
You can also fill NaN values with a specified value using the fillna method:
df = df.fillna(value)
df.fillna(value) returns a new DataFrame with all NaN values filled with the specified value.