Determine the number of NA values in a column

后端 未结 14 1400
眼角桃花
眼角桃花 2020-12-02 04:17

I want to count the number of NA values in a data frame column. Say my data frame is called df, and the name of the column I am considering is

相关标签:
14条回答
  • 2020-12-02 04:57

    You can use this to count number of NA or blanks in every column

    colSums(is.na(data_set_name)|data_set_name == '')
    
    0 讨论(0)
  • 2020-12-02 04:58

    I read a csv file from local directory. Following code works for me.

    # to get number of which contains na
    sum(is.na(df[, c(columnName)]) # to get number of na row
    
    # to get number of which not contains na
    sum(!is.na(df[, c(columnName)]) 
    
    #here columnName is your desire column name
    
    0 讨论(0)
提交回复
热议问题