Skip to content

Instantly share code, notes, and snippets.

@ansaso
Last active August 23, 2020 19:21
Show Gist options
  • Save ansaso/a77b2a88dc1a992895be7d732f3bc5f3 to your computer and use it in GitHub Desktop.
Save ansaso/a77b2a88dc1a992895be7d732f3bc5f3 to your computer and use it in GitHub Desktop.
pandas df.info() as object instead of print
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