Python | Pandas dataframe.info()
When working with data in Python understanding the structure and content of our dataset is important. The dataframe.info() method in Pandas helps us in providing a concise summary of our DataFrame and it quickly assesses its structure, identify issues like missing values and optimize memory usage.
Key features of dataframe.info() include:
- Number of entries (rows) in the DataFrame.
- Column names and their associated data types like integer, float, object, etc.
- The number of non-null values in each column which is useful for spotting missing data.
- A summary of how much memory the DataFrame is consuming.
In this article we'll see how to use dataframe.info() to streamline our data exploration process.
Lets see a examples for better understanding. Here we’ll be using the Pandas library and a random dataset which you can download it from here. We will display a concise summary of the DataFrame using the info() method.
import pandas as pd
df = pd.read_csv("/content/nba.csv")
df.info()
Output :
Here info() provides an overview of the DataFrame's structure such as number of entries, column names, data types and non-null counts.
Syntax of dataframe.info()
DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None)
Parameters:
1. verbose: Controls the level of detail in the summary.
- True: Displays the full summary.
- False: Provides a concise summary.
2. memory_usage: Shows memory usage of the DataFrame.
- True: Displays basic memory usage.
- deep: Provides a detailed view, including memory usage of each column’s objects.
3. null_counts: Controls whether the number of non-null entries is displayed.
- True: Shows non-null counts for each column.
- False: Excludes non-null counts for a cleaner summary.
Lets see more examples:
1. Shortened Summary with verbose=False
Here we will use the verbose parameter to generate a more concise summary of the DataFrame. By setting verbose=False we exclude detailed column information such as the number of non-null values which is useful when working with large datasets where we might not need all the details.
import pandas as pd
df = pd.read_csv("/content/nba.csv")
df.info(verbose=False)
Output :

2. Full Summary with Memory Usage
We will use the memory_usage parameter to include detailed memory consumption information in the summary. By setting memory_usage=True, the dataframe.info() method will provide an overview of how much memory the DataFrame uses including both data and index memory usage.
import pandas as pd
df = pd.read_csv("/content/nba.csv")
df.info(memory_usage=True)
Output :

By using dataframe.info() we can ensure our datasets are ready for deeper analysis and avoid common issues like missing values or incorrect data types.