How can i get the count of total non empty elements in a pandas column?
print(len(newDF.Paid_Off_In_Days).where(newDF.Paid_Off_In_Days != ''))
Data type is int
I get error:
AttributeError: 'int' object has no attribute 'where'
Paid_Off_In_Days Credit_Amount
1 150
15 500
80
18 90
1200
29 600
If empty means empty string compare for mask and use sum for count True values:
print((newDF.Paid_Off_In_Days != '').sum())
If empty means missing value use Series.count:
print (newDF)
Paid_Off_In_Days col
0 1.0 a
1 15.0 s
2 NaN d
3 18.0 NaN
4 NaN f
5 29.0 NaN
print(newDF.Paid_Off_In_Days.count())
4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With