Last active
April 27, 2020 16:15
-
-
Save austinbrian/c7970de49bed4010fbeb64e0b3c70b89 to your computer and use it in GitHub Desktop.
A couple of useful settings for displaying pandas dataframes
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
# Pandas settings to include on import | |
import pandas as pd | |
import numpy as np | |
pd.set_option('display.max_rows',1000) | |
pd.set_option('display.max_columns',1000) | |
# Includes commas in outputs > 1,000, and formats as integers if integers | |
# If not integers, formats to two decimal places | |
pd.set_option('display.float_format', lambda x: "{:,.0f}".format(x) if x.is_integer() | |
else "{:,.2f}".format(x)) | |
# a more complicated version | |
pd.set_option('display.float_format', lambda x: "{:,.0f}".format(x) if x.is_integer() else ( | |
"{:,.2f}".format(x) if x>1 else ( | |
"{:,.2%}".format(x) if x > -1 else ( | |
"{:,.2f}".format(x)))) | |
) | |
pd.options.mode.chained_assignment = None # default='warn' | |
# Set shell to show all lines of output | |
from IPython.core.interactiveshell import InteractiveShell | |
InteractiveShell.ast_node_interactivity = 'all' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment