Header Ads Widget

Responsive Advertisement

What is the difference between size and count.


In this article we will discuss about the difference between size and count. We have learn some attribute in previous slides. In this section we will learn about the difference between Size and Count() function. 

#Size defined as Size counts NaNs         

#Count Define as Count does not coutn NaN 

Size does indeed count NaNs, this is actually a consequence of the fact that size returns the size (or the length) of the object it is called on. Let us under stand with example. In this example we define a list and passed to Series, after all of this we apply attribute Size on series object  and apply count function with it.

import pandas as pd

import numpy as np

list1=[np.NaN,2,3,4,1,2,3,4]

s1=pd.Series(list1)

print(s1)

print("Size",s1.size)

print("Count",s1.count())

 



In this above program we will use size and count function. Size is attribute which define the size of Series means IT count NaN values also. The below Series attribute having Eight(8) elements or values. Means s1.size return 8 but in the case of Count Function Will not count NaN values means it neglect NaN values measn s1.count return Seven (7).

import pandas as pd

import numpy as np

list1=[np.NaN,2,3,4,1,2,3,4]

s1=pd.Series(list1) 

print("Size",s1.size)

print("Count",s1.count())


What is the difference between DataFrame and series? What is difference between DataFrame and array? What is the difference between series and array? What is the difference between pandas series and list? difference between series and dataframe in python difference between series and dataframe in tabular form compare series and dataframe in pandas with examples difference between series and list what is dataframe in python the size of a pandas dataframe is immutable true or false difference between pandas series and numpy array in both series and dataframe data values are mutable

Post a Comment

0 Comments