Find the option for pd.head() in colab

Viewed 904

I am doing colab, and I found something weird see this: pd.head() head

But I want to do like this: enter image description here

Any solution for this problem? Thank you!

2 Answers

Unless you are printing a dataframe using print google colab automatically displays the data in table format. If in some cases it doesn't you can force it to show using display

You can use display form ipython to print mutiple tables.

from IPython.display import HTML, display
display(df1)
display(df2)

enter image description here

You can also use google.colab.data_table extension to show a table with more functionality.

%load_ext google.colab.data_table
from IPython.display import HTML, display
display(df1)
display(df2)

enter image description here

Add:

At the first time %load_ext google.colab.data_table doesn't work.

So do %load_ext google.colab.data_table first,

And fo %unload_ext google.colab.data_table

then do pd.head() will works well !

Related