How to count nan values in a pandas DataFrame?

前端 未结 7 1869
天涯浪人
天涯浪人 2020-12-18 18:40

What is the best way to account for (not a number) nan values in a pandas DataFrame?

The following code:

import numpy as np
import pandas as pd
dfd =         


        
7条回答
  •  别那么骄傲
    2020-12-18 19:23

    To count just null values, you can use isnull():

    In [11]:
    dfd.isnull().sum()
    
    Out[11]:
    a    2
    dtype: int64
    

    Here a is the column name, and there are 2 occurrences of the null value in the column.

提交回复
热议问题