I've seen a lot of very helpful posts on using prettyprint and such; they have been very helpful -- thanks.
What I'm wondering if there is anyway to print a dataframe from a function and have it output as "prettily" as Jupyter notebook does:
My main reason is I would like to use pandas's styling functions to highlight/shade. I also want to print from a function and not a Jupyter code box if possible as I have some packages I have created and I may want to spit out 2 or more dataframes in a call.
Using prettyprint or print() alone gives a purely text output:
> Year Month Mean Maximum Temperature Albury \
> 672 1955 January 30.8
> 673 1955 February 27.9
> 674 1955 March 26.7
> 675 1955 April 22.1
> ....
I'd like the graphical output. Not using print(), e.g.
historic_dataframe
does nothing if within a function.
My thanks for your time.
The copy() method returns a copy of the DataFrame. By default, the copy is a "deep copy" meaning that any changes made in the original DataFrame will NOT be reflected in the copy.
Use display
from IPython
instead of print
import pandas as pd
from IPython.display import display
df = pd.DataFrame(pd.np.random.random((10, 10)))
display(df)
display docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With