Check if all values in dataframe column are the same

后端 未结 3 707
时光取名叫无心
时光取名叫无心 2020-12-09 15:48

I want to do a quick and easy check if all column values for counts are the same in a dataframe:

In:

import pandas as pd

d = {\'names\'         


        
3条回答
  •  自闭症患者
    2020-12-09 16:51

    Update using np.unique

    len(np.unique(df.counts))==1
    False
    

    Or

    len(set(df.counts.tolist()))==1
    

    Or

    df.counts.eq(df.counts.iloc[0]).all()
    False
    

    Or

    df.counts.std()==0
    False
    

提交回复
热议问题