How To Get The Size Of A DataFrame?


How To Get The Size Of A DataFrame?

Table Of Contents:

  1. Syntax To Get Size Of Data Frame.
  2. Examples Of Getting Size Of DataFrame.

(1) Syntax:

pandas.DataFrame.size

Description:

  • Return an int representing the number of elements in this object.

  • Return the number of rows if Series. Otherwise, return the number of rows times the number of columns if DataFrame.

     

(2) Examples Of Columns :

Example-1

import pandas as pd
student = {'Name':['Subrat','Abhispa','Arpita','Anuradha','Namita'],
          'Roll_No':[100,101,102,103,104],
          'Subject':['Math','English','Science','History','Commerce'],
          'Mark':[95,88,76,73,93]}
student_object = pd.DataFrame(student)
student_object

Output:

student_object.size

Output:

20 = 5 * 4

Example-1

s = pd.Series({'a': 1, 'b': 2, 'c': 3})
s

Output:

a    1
b    2
c    3
dtype: int64
s.size

Output:

3

Leave a Reply

Your email address will not be published. Required fields are marked *