Source Code:
(back to article)
import pandas as pd # Create a sample DataFrame df = pd.DataFrame({ 'A': [1, 2, 3, 4, float('nan')], 'B': [float('nan'), 2, 3, 4, 5], 'C': [1, 2, float('nan'), 4, 5] }) # Check for NaN values nan_mask = df.isna() # Print the result print(nan_mask)
Result:
Report an issue