Last active
July 6, 2016 23:05
-
-
Save dmyersturnbull/035876942070ced4c565e4e96161be3e to your computer and use it in GitHub Desktop.
Pretty-print the head of a Pandas table in a Jupyter notebook and show its dimensions. Allows showing multiple tables per cell.
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
| from IPython.display import display, Markdown | |
| import pandas as pd | |
| def head(df: pd.DataFrame, n_rows:int=1) -> None: | |
| """Pretty-print the head of a Pandas table in a Jupyter notebook and show its dimensions.""" | |
| display(Markdown("**whole table (below):** {} rows × {} columns".format(len(df), len(df.columns)))) | |
| display(df.head(n_rows)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment