Last active
August 23, 2020 19:21
-
-
Save ansaso/a77b2a88dc1a992895be7d732f3bc5f3 to your computer and use it in GitHub Desktop.
pandas df.info() as object instead of print
This file contains hidden or 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 log_df(df:pd.DataFrame, name: str='') -> str: | |
return f''' | |
___________________ | |
# DATAFRAME: {name} | |
___________ | |
## COLUMNS | |
size: {df.size} | |
shape: {df.shape} | |
nans: | |
{df.isna().sum()} | |
dtypes: | |
{df.dtypes} | |
________ | |
## INDEX | |
size: {df.index.size} | |
shape: {df.index.shape} | |
nans: | |
{df.index.isna().sum()} | |
_______ | |
## HEAD | |
{df.head()} | |
___________________ | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment