9951 explained code solutions for 126 technologies


python-pandasHow to count dataframe NaN rows


import pandas as pd

data = pd.DataFrame({
  'Vendor': ['US', 'US', None, 'KR', None],
  'Phone': ['ip5', 'ip6', 'ip8', 'sms', 'xi'],
  'Phone Price': [204, 304, 404, 405, 305]
})

res = len(data[data['Vendor'].isna()])ctrl + c
import pandas as pd

load Pandas module

pd.DataFrame

creates Pandas DataFrame object

len(

returns length (rows count) of a given dataframe

.isna()

filters only NaN values

Vendor

column to find NaN values in

res

will contain final count