You can use the .isna().any() method to detect any missing values in a Pandas dataframe.
Here's an example:
import pandas as pd# create a sample dataframe with missing valuesdata = {'name': ['John', 'Jane', 'Mike', 'Susan'], 'age': [30, 25, None, 40], 'gender': ['M', 'F', None, 'F']}df = pd.DataFrame(data)# check for missing values in the dataframeprint(df.isna().any()) |
This will output a boolean series with True values for columns that contain at least one missing value:
name False
age True
gender True
dtype: bool
In this example, we can see that the age and gender columns have at least one missing value, while the name column does not.