Showing df.info(), df.head(), df.shape, df.dtypes in one step

Viewed 242

when using Jupyter Notebook, I have to make separate spaces for df.info(), df.head(), etc. mentioned in the title of the question.

Jupyter Notebook

Is there a way to put all of these in one block like in 2nd picture, and showing all the information Jupyter Notebook

3 Answers

use a comma on the same line

df.info(), df.head(), df.shape, df.dtypes

you can put them in a same line or in separate lines. but it will still give the same results.

put them in same line using commas:

df.info(), df.head(), df.head(), df.dtypes

Other option is use display

display(df.info())
display(df.head())
display(df.shape())

Depending on the version of jupyter, you may have to do the import from IPython.display import display Another advantage of display is in case of printing multiple dataframes. The output would be same as if you have printed one df, which is not in the case of using ,

Related