How to usedf.size in Python Pandas

This will return the size of dataframe  i.e. rows*columns

Syntax:

dataframe.size

where, dataframe is the input dataframe

Example: Python code to create a student dataframe and display size

Python3




# import pandas module
import pandas as pd
  
# create a dataframe
# with 5 rows and 3 columns
data = pd.DataFrame({
    'name': ['sravan', 'ojsawi', 'bobby', 'rohith', 'gnanesh'],
    'subjects': ['java', 'php', 'html/css', 'python', 'R'],
    'marks': [98, 90, 78, 91, 87]
})
  
# display dataframe
print(data)
  
# get the size
data.size


Output:

Get Size of the Pandas DataFrame

In this article, we will discuss how to get the size of the Pandas Dataframe using Python.

Similar Reads

Method 1 : Using df.size

This will return the size of dataframe  i.e. rows*columns...

Method 2 : Using df.shape

...

Method 3: Using df.ndim

This function will return the number of rows and columns in the dataframe...