Count NaN Values in pandas DataFrame in Python (Examples) | is.na & sum Functions | By Row & Column

preview_player
Показать описание
Python code of this video:

import pandas as pd # Import pandas library to Python

data = pd.DataFrame({'x1':[1, float('NaN'), 2, 3, float('NaN'), 4], # Create example DataFrame
'x2':[9, float('NaN'), 9, 9, 9, 9],
'x3':range(1, 7)})
print(data) # Print example DataFrame

# x1 2
# x2 1
# x3 0
# dtype: int64

print(data['x1'].isna().sum()) # Number of NaNs in one column
# 2

# 0 0
# 1 2
# 2 0
# 3 0
# 4 1
# 5 0
# dtype: int64

# 1

# 3

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

thanks for posting these videos man. Best source to answer my questions in R and Python!

jayparikh