The Wayback Machine - https://web.archive.org/web/20240707141115/https://www.geeksforgeeks.org/python-pandas-dataframe-info/
Open In App

Python | Pandas dataframe.info()

Last Updated : 18 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The `dataframe.info()` function in Pandas proves to be an invaluable tool for obtaining a succinct summary of a dataframe. This function is particularly useful during exploratory analysis, offering a quick and informative overview of the dataset. Leveraging `dataframe.info()` is an efficient way to gain insights into the structure and characteristics of the data, making it an essential step in the data analysis workflow.

Pandas dataframe.info() Syntax

Syntax: DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None)

Parameters: 

  • verbose : Whether to print the full summary. None follows the display.max_info_columns setting. True or False overrides the display.max_info_columns setting. 
  • buf : writable buffer, defaults to sys.stdout 
  • max_cols : Determines whether full summary or short summary is printed. None follows the display.max_info_columns setting. 
  • memory_usage : Specifies whether total memory usage of the DataFrame elements (including index) should be displayed. None follows the display.memory_usage setting. True or False overrides the display.memory_usage setting. A value of ‘deep’ is equivalent of True, with deep introspection. Memory usage is shown in human-readable units (base-2 representation).
  • null_counts : Whether to show the non-null counts. If None, then only show if the frame is smaller than max_info_rows and max_info_columns. If True, always show counts. If False, never show counts.

For link to the CSV file used in the code, click here

What is dataframe.info() Function in Pandas ?

The `DataFrame.info()` function in Pandas is a method used to obtain a concise summary of a DataFrame’s structure and information. When called on a Pandas DataFrame, it provides essential details such as the total number of non-null values, data types of each column, and memory usage. This summary is beneficial for quickly assessing the completeness of the dataset, identifying potential missing values, and understanding the overall data types present in the DataFrame.

Pandas dataframe.info() Examples

There are some examples of dataframe.info() examples those shown the advantages uses of the dataframe.info() function. those are following.

Printing the summary of a DataFram using Pandas info() Function 

In this example code utilizes the pandas library to work with tabular data in Python. It imports the library as ‘pd’ and reads a CSV file named “nba.csv” into a DataFrame (df). Finally, it prints the contents of the DataFrame, displaying the structured representation of the data from the CSV file.

Python3




# importing pandas as pd
import pandas as pd
 
# Creating the dataframe
df = pd.read_csv("nba.csv")
 
# Print the dataframe
df


Output :

second-print-

Print the Full Summary of the Dataframe

In below example code uses the `info()` method on a DataFrame named `df` to display a concise summary of its structure.

Python3




# to print the full summary
df.info()


Output : 

final-reviewAs we can see in the output, the summary includes list of all columns with their data types and the number of non-null values in each column. we also have the value of rangeindex provided for the index axis. 

Summarize a DataFrame in Pandas use info() Function

Note : In order to print the short summary, we can use the verbose parameter and set it to False.

In this example code utilizes the Pandas library to handle tabular data. It imports the library as ‘pd’ and reads a CSV file named “nba.csv” into a Pandas DataFrame called ‘df’. The last line prints a concise summary of the DataFrame, excluding verbose details, using the `info()` function with the parameter ‘verbose’ set to False. This summary includes information about the columns, data types, and memory usage.

Python3




# importing pandas as pd
import pandas as pd
 
# Creating the dataframe
df = pd.read_csv("nba.csv")
 
# Print the short summary of the
# dataframe by setting verbose = False
df.info(verbose = False)


Output : 

As, we can see in the output, the summary is very crisp and short. It is helpful when we have 1000s of attributes in dataframe. 

Use info() Function to Print a Full Summary of the Dataframe and Exclude the Null-Counts

Note : In order to print the full summary, with null-counts excluded, we can use null-counts parameter and set it to be false.

In this example code uses the pandas library in Python to read a CSV file named “nba.csv” into a DataFrame called ‘df.’ The last line prints a concise summary of the DataFrame, including information about its structure, data types, and non-null counts for each column, with null counts excluded.

Python3




# importing pandas as pd
import pandas as pd
 
# Creating the dataframe
df = pd.read_csv("nba.csv")
 
# Print the full summary of the dataframe
# with null count excluded
df.info(verbose = True, null_counts = False)


Output : 

As, we can see in the output, the summary is full but null-counts are excluded.



Previous Article
Next Article

Similar Reads

Login Application and Validating info using Kivy GUI and Pandas in Python
Prerequisites : Kivy, Pandas Kivy is a multiplatform GUI library, known for being responsive. It provides management of multiple screens in a single application. In this application we will be using multiple screens to log in user's info and validate it. We will save the information in a csv file and use pandas to validate the information inside of
5 min read
Python | Pandas DataFrame.fillna() to replace Null values in dataframe
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Sometimes csv file has null values, which are later displayed as NaN in Data Frame. Just like the pandas dropna() method manages and rem
3 min read
Python IMDbPY – Movie info set
IMDb data base have every information of the movie i.e when movie released, rating, locations etc but in order to retrieve them problem occur as there will be lots of web pages which can be both time-and bandwidth-consuming, especially if you’re interested in only a small part of the information. If we want to fetch only specific information we can
1 min read
Python IMDbPY – Person info set
IMDb data base have every information of the person i.e person having what awards, biography etc but in order to retrieve them problem occur as there will be lots of web pages which can be both time-and bandwidth-consuming, especially if you’re interested in only a small part of the information. If we want to fetch only specific information we can
1 min read
Python IMDbPY – Default info of Company object
In this article we will see how we can achieve the set of information which retrieved by default by get_company method, with the help of get_company_infoset we can know all the information that we can achieve of the company. But all the information is not extracted as it will be time consuming process. In order to know the default information that
1 min read
Python IMDbPY – Default info of Movie object
In this article we will see how we can achieve the set of information which retrieved by default by get_movie method, with the help of get_movie_infoset we can know all the information that we can achieve of the movie. But all the information is not extracted as it will be time consuming process. In order to know the default information that a movi
1 min read
Python IMDbPY – Company info set
IMDb data base have every information of the movies and companies i.e person having what date it was build what movies it has made etc but in order to retrieve them problem occur as there will be lots of web pages which can be both time-and bandwidth-consuming, especially if you’re interested in only a small part of the information. If we want to f
1 min read
Python IMDbPY – Default info of Person object
In this article we will see how we can achieve the set of information which retrieved by default by get_person method, with the help of get_person_infoset we can know all the information that we can achieve of the person. But all the information is not extracted as it will be time consuming process. In order to know the default information that a m
1 min read
Python IMDbPY – Info set to keys of Movie object
In this article we will see how we can convert info set to keys, we can know info sets of movie by get_movie_infoset, but even after getting the info set we are unable to use like dictionary. In order to use info set as dictionary keys we have to use infoset2keys method. Syntax : movie.infoset2keys Here movie is the imdb Movie object Action perform
2 min read
Python IMDbPY – Info set to keys of Person object
In this article we will see how we can convert info set to keys, we can know info sets of movie by get_person_infoset, but even after getting the info set we are unable to use like dictionary. In order to use info set as dictionary keys we have to use infoset2keys method. Syntax : person.infoset2keys Here movie is the imdb Person object Action perf
3 min read
three90RightbarBannerImg