Created
September 6, 2017 16:12
-
-
Save Ailuropoda1864/edd045d8de389ab1b2862eec6c9a2532 to your computer and use it in GitHub Desktop.
This function prints the number and percentage of null values in each column in a pandas DataFrame.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def show_null(dataframe): | |
""" | |
prints the number and percentage of null values in each column | |
:param dataframe: a pandas DataFrame | |
:return: None | |
""" | |
if dataframe.isnull().sum().sum() == 0: | |
print('No null in the dataframe.') | |
else: | |
print('Number of nulls in each column:\n{}\n'.format( | |
dataframe.isnull().sum() | |
)) | |
print('Percentage of nulls in each column:\n{}\n'.format( | |
dataframe.isnull().sum() / len(dataframe) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment