Jupyter notebooks (Python) return the value of the last variable in a cell in a pretty printed format.
Using print(df)
won't output the dataframe pretty printed. But this will pretty print df
to the Jupyter notebook:
In[1]:
import pandas as pd
import numpy as np
filename = "Umsaetze.csv"
csv_file = f"~/Desktop/{filename}"
# read csv into DataFrame
df = pd.read_csv(csv_file, sep=";", decimal=",")
df
How can I print several variables in a pretty printed format?
This here will only print df3
in a pretty printed format:
In[2]:
df1
df2
df3
Edit
Here is the answer (from: Show DataFrame as table in iPython Notebook)
from IPython.display import display, HTML
# Assuming that dataframes df1 and df2 are already defined:
print("Dataframe 1:")
display(df1.head())
print("Dataframe 2:")
display(df2.head())