I notice that when printing multiple dataframes defined in a function with only the names of the dataframes such as
list_1 = range(10)
list_2 = range(10)
list_3 = np.random.randn(10)
df = pd.DataFrame({ 'list_1': list_1, 'list_2':list_2, 'list_3':list_3 })
df
list_11 = range(10)
list_22 = range(10)
list_33 = np.random.randn(10)
df1 = pd.DataFrame({ 'list_11': list_11, 'list_22':list_22, 'list_33':list_33 })
df1
only the last one(ie. df1
) would be displayed:
unless I used print(df)
:
list_1 = range(10)
list_2 = range(10)
list_3 = np.random.randn(10)
df = pd.DataFrame({ 'list_1': list_1, 'list_2':list_2, 'list_3':list_3 })
print(df)
list_11 = range(10)
list_22 = range(10)
list_33 = np.random.randn(10)
df1 = pd.DataFrame({ 'list_11': list_11, 'list_22':list_22, 'list_33':list_33 })
df1
but the first table will look different format than the second one:
How can I have both tables formatted like the second one? What if the code is part of a function(I guess that means print locally?) ?