pandas value_counts applied to each column

前端 未结 6 1006
甜味超标
甜味超标 2020-12-09 17:30

I have a dataframe with numerous columns (≈30) from an external source (csv file) but several of them have no value or always the same. Thus, I would to see qui

6条回答
  •  情书的邮戳
    2020-12-09 17:44

    Code like the following

    df = pd.DataFrame(data=[[34, 'null', 'mark'], [22, 'null', 'mark'], [34, 'null', 'mark']], columns=["id", 'temp', 'name'], index=[1, 2, 3]) 
    result2 = df.apply(pd.value_counts)
    result2
    

    will produce:

提交回复
热议问题