Difference between revisions of "Pandas options"

From Bitnami MediaWiki
Jump to navigation Jump to search
(Created page with "===Pandas Options===")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
===Pandas Options===
 
===Pandas Options===
 +
<syntaxhighlight lang=python>
 +
pd.get_option('display.max_rows')
 +
  60
 +
pd.set_option('display.max_rows', 200)
 +
# reset to 60
 +
pd.reset_option('display.max_rows')
 +
 +
# show more columns
 +
pd.set_option('display.max_columns', 30)
 +
 +
# change column width (param=characters)
 +
pd.set_option('display.max_colwidth', 500) 
 +
 +
# precision for floats
 +
pd.set_option('display.precision', 4)
 +
 +
# display for numbers
 +
pd.set_option('display.float_format', '{:,}'.format)
 +
pd.set_option('display.float_format', '{:.4f}'.format) # test this
 +
# decimal format (100,000.12)
 +
pd.set_option('display.float_format', '{:,.2f}'.format)
 +
# percentages
 +
pd.set_option('display.float_format', '{:.2f}%'.format)
 +
# dollar sign
 +
pd.set_option('display.float_format', '${:.2f}'.format)
 +
 +
# use plotly or altair
 +
pd.set_option('plotting.backend', 'altair')
 +
 +
# output of info()
 +
pd.set_option('display.max_info_columns', 200)
 +
pd.set_option('display.max_info_rows', 5)
 +
 +
# Print current option settings
 +
pd.describe_option()
 +
# Search options by keyword
 +
pd.describe_option('rows')
 +
 +
 +
</syntaxhighlight>

Latest revision as of 22:42, 21 February 2023

Pandas Options[edit]

pd.get_option('display.max_rows')
  60
pd.set_option('display.max_rows', 200)
# reset to 60
pd.reset_option('display.max_rows')

# show more columns
pd.set_option('display.max_columns', 30)

# change column width (param=characters)
pd.set_option('display.max_colwidth', 500)  

# precision for floats
pd.set_option('display.precision', 4)

# display for numbers 
pd.set_option('display.float_format', '{:,}'.format)
pd.set_option('display.float_format', '{:.4f}'.format) # test this
# decimal format (100,000.12)
pd.set_option('display.float_format', '{:,.2f}'.format) 
# percentages
pd.set_option('display.float_format', '{:.2f}%'.format)
# dollar sign 
pd.set_option('display.float_format', '${:.2f}'.format)

# use plotly or altair
pd.set_option('plotting.backend', 'altair')

# output of info()
pd.set_option('display.max_info_columns', 200)
pd.set_option('display.max_info_rows', 5)

# Print current option settings
pd.describe_option()
# Search options by keyword
pd.describe_option('rows')