How to Print Information of Pandas DataFrame?

Print Information of a Pandas DataFrame

To print information of Pandas DataFrame, call method. The method returns nothing but just prints information about this DataFrame.


The syntax to use info() method of a DataFrame is, buf=None, max_cols=None, memory_usage=None, show_counts=None, null_counts=None)


1. Print DataFrame information

In the following program, we have created a DataFrame. We shall print this DataFrame’s information using method.

Python Program

import pandas as pd

df = pd.DataFrame(
    [['abc', 22],
    ['xyz', 25],
    ['pqr', 31]],
    columns=['name', 'age'])
Run Code Copy


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3 entries, 0 to 2
Data columns (total 2 columns):
name    3 non-null object
age     3 non-null int64
dtypes: int64(1), object(1)
memory usage: 128.0+ bytes

If we observe, info() method printed the type of this object, range, columns, number of entries in each columns, if the columns are non-null, datatype of columns, and memory usage of this DataFrame.


In this tutorial of Python Examples, we learned how to print the information of a DataFrame using method.

Related Tutorials

Code copied to clipboard successfully 👍