Last active
September 22, 2019 08:36
-
-
Save Alex-Kopylov/697e9a985a0bd4cb025a81502e93b077 to your computer and use it in GitHub Desktop.
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
def resumetable(df): | |
print(f"Dataset Shape: {df.shape}") | |
summary = pd.DataFrame(df.dtypes,columns=['dtypes']) | |
summary = summary.reset_index() | |
summary['Name'] = summary['index'] | |
summary = summary[['Name','dtypes']] | |
summary['Missing'] = df.isnull().sum().values | |
summary['Uniques'] = df.nunique().values | |
summary['First Value'] = df.loc[0].values | |
summary['Second Value'] = df.loc[1].values | |
summary['Third Value'] = df.loc[2].values | |
for name in summary['Name'].value_counts().index: | |
summary.loc[summary['Name'] == name, 'Entropy'] = round(stats.entropy(df[name].value_counts(normalize=True), base=2),2) | |
return summary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment