Last active
May 17, 2023 11:32
-
-
Save chrisRedwine/356eb109e98b6caa8acd0296ccedc423 to your computer and use it in GitHub Desktop.
Pandas CSS for Jupyter Notebooks
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
body { | |
margin: 0; | |
font-family: Helvetica; | |
} | |
table.dataframe { | |
border-collapse: collapse; | |
border: none; | |
} | |
table.dataframe tr { | |
border: none; | |
} | |
table.dataframe td, table.dataframe th { | |
margin: 0; | |
border: 1px solid white; | |
padding-left: 0.25em; | |
padding-right: 0.25em; | |
} | |
table.dataframe th:not(:empty) { | |
background-color: #fec; | |
text-align: left; | |
font-weight: normal; | |
} | |
table.dataframe tr:nth-child(2) th:empty { | |
border-left: none; | |
border-right: 1px dashed #888; | |
} | |
table.dataframe td { | |
border: 2px solid #ccf; | |
background-color: #f4f4ff; | |
} |
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
%matplotlib inline | |
%load_ext autoreload | |
# always reload modules marked with "%aimport" | |
%autoreload 1 | |
import os | |
import sys | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from IPython.display import HTML | |
root_dir = os.path.dirname(os.path.dirname(os.getcwd())) | |
notebooks_dir = os.path.join(root_dir, 'notebooks') | |
src_dir = os.path.join(root_dir, 'src') | |
data_dir = os.path.join(root_dir, 'data') | |
sql_path = os.path.join(data_dir, 'sql') | |
# add the 'src' directory as one where we can import modules | |
sys.path.append(src_dir) | |
LARGE_FIGSIZE = (12, 8) | |
# apply nice styling to pandas dataframes | |
pd.set_option("display.max_rows", 16) | |
pd.set_option('display.float_format', lambda x: '{:.2f}'.format(x)) | |
with open(os.path.join(notebooks_dir, 'resources', 'pd.css'), 'r') as f: | |
HTML('<style>{}</style>'.format(f.read())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment