Size and shape of a dataframe in pandas python

Size and shape of a dataframe in pandas python: Size of a dataframe is the number of fields in the dataframe which is nothing but number of rows * number of columns. Shape of a dataframe gets the number of rows and number of columns of the dataframe.

Lets see on how to

  • Get the Size of the dataframe in pandas python.
  • Get the shape of the dataframe in pandas python.

First let’s create a dataframe


import pandas as pd
import numpy as np

#Create a DataFrame
df1 = {
     'Name':['George','Andrea','micheal','maggie','Ravi','Xien','Jalpa'],
   'Mathematics_score':[62,47,55,74,32,77,86]}

df1 = pd.DataFrame(df1,columns=['Name','Mathematics_score'])
print(df1)

df1 will be

Size and shape of a dataframe in pandas 1

 

Get size of the dataframe in pandas python:

# Get the size of the dataframe
df1.size

Result:

14

 

Get shape of the dataframe in pandas python:


# Get the shape of the dataframe
df1.shape

Result:

(7, 2)

 

p Size and shape of a dataframe in pandas python                                                                                                           n Size and shape of a dataframe in pandas python

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.