Skip to content

Instantly share code, notes, and snippets.

@joefromct
Created November 24, 2020 19:51
Show Gist options
  • Save joefromct/58c5e85cd1b06d89a1414b26c64ea288 to your computer and use it in GitHub Desktop.
Save joefromct/58c5e85cd1b06d89a1414b26c64ea288 to your computer and use it in GitHub Desktop.
pandas set_options.py
import pandas as pd
def set_options(*seq):
"https://toolz.readthedocs.io/en/latest/_modules/toolz/itertoolz.html#partition"
assert len(seq) % 2 == 0, "I need pairs of option/values?"
options = [iter(seq)] * 2
for opt, val in list(zip(*options)):
pd.set_option(opt, val)
print(f"{opt} -> {val}")
set_options("display.float.format" , '{:,.2f}'.format ,
"display.max_colwidth" , None ,
"display.max.columns" , None ,
"display.precision" , 2)
# display.float.format -> <built-in method format of str object at 0x7fc6fc8d57b0>
# display.max_colwidth -> None
# display.max.columns -> None
# display.precision -> 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment