Output format without print function
If I run a JupyterNotebook cell with
dataframe.describe()
a pretty fromatted table will be printed like that: VSCode JupyterNotebook dataframe.describe() solo cell printing format
Output format with print function
If I run a cell with more than just one line code dataframe.describe() would not print anythink. Therefore I need to call
print(dataframe.describe()).
This leads to a totally different formatting though: VSCode JupyterNotebook printing dataframe.describe() with print function
Is there a way to print dataframe.describe() in the first format?
There are multiple things to say here:
Jupyter Notebooks can only print out one object at a time when simply calling it by name (e.g.
dataframe). If you want, you can use one cell per command to get the right format.If you use the function
print, it will print anything as text because print is using the functionto_stringfor any object it gets. This ispythonlogic - in contrast, option 1) is Jupyter-specific...If you don't want to use a seperate cell and still get the right formatting, there are several options, one might be this: