Prompt:

"Generate a Python function that outputs a summary table of missing values, including percentage missing and total missing."

Output:

def missing_values_summary(df): summary = pd.DataFrame({ 'Total Missing': df.isnull().sum(), 'Percent Missing': (df.isnull().sum() / len(df)) * 100 }) return summary[summary['Total Missing'] > 0]

Example usage

data = {'A': [1, 2, None, 4], 'B': [None, 2, 3, None], 'C': [1, 2, 3, 4]} df = pd.DataFrame(data) missing_values_summary(df)

Output Explanation: A table showing the total number and percentage of missing values per column.