To obtain the number of elements in a given pandas DataFrame object, we use the attribute DataFrame.size
.
Since it is an attribute, DataFrame.size
takes no parameter values.
The DataFrame.size
attribute returns an int
representing the number of elements in a DataFrame.
import pandas as pd# creating a dataframedf = pd.DataFrame({'AGE': [ 20, 29],'HEIGHT': [94, 170],'WEIGHT': [80, 115]})print(df)# obtaining the number of elements in dfprint("No of elements =", df.size)
pandas
library.df
.df
.Data.frame.size
attribute, we obtain the number of elements in df
.