Data cleaning involves handling missing values, duplicates, and inconsistent data. Key methods: dropna(), fillna(), drop_duplicates(), replace().
import pandas as pd
import numpy as np
df = pd.DataFrame({"a": [1, np.nan, 3], "b": [4, 5, np.nan]})
print(df.fillna(0))Count the number of missing values in each column and print the result.
Loading Python runtime (Pyodide)...
Fill missing age values with the mean age and print the result.
Loading Python runtime (Pyodide)...