Using pd.options.display
This answer is a variation of the prior answer by lucidyan. It makes the code more readable by avoiding the use of set_option.
After importing pandas, as an alternative to using the context manager, set such options for displaying large dataframes:
def set_pandas_display_options() -> None:
"""Set pandas display options."""
# Ref: https://stackoverflow.com/a/52432757/
display = pd.options.display
display.max_columns = 1000
display.max_rows = 10_000
display.max_colwidth = 199
display.width = 1000
# display.precision = 2 # set as needed
# display.float_format = lambda x: "{:,.2f}".format(x) # set as needed
set_pandas_display_options()
After this, you can use either display(df) or just df if using a notebook, otherwise print(df).
Regarding any columns containing floating point numbers while having the object dtype, such columns need to first be converted to the float dtype before the display precision will apply to them.
Using to_string
Pandas 0.25.3 does have DataFrame.to_string and Series.to_string methods which accept formatting options.
Using to_markdown
If what you need is markdown output, Pandas 1.0.0 has DataFrame.to_markdown and Series.to_markdown methods.
For markdown, you may also need to install the tabulate package:
pip install tabulate
Using to_html
If what you need is HTML output, Pandas 0.25.3 does have a DataFrame.to_html method but not a Series.to_html. Note that a Series can be converted to a DataFrame.
pd.set_option('display.max_rows', 1000)for example, the colouring is something else, I assume you are talking about colouring the html repr output. I don't think this is built in at all.