'<' not supported between instances of 'float' and 'str' Error for Tukey HSD Test

后端 未结 1 1609
轻奢々
轻奢々 2021-01-17 03:07

I get a strange error when running the Tukey test. I hope somebody is able to help me with this as I tried a lot. This is my dataframe:

    Name      Score
1         


        
相关标签:
1条回答
  • 2021-01-17 03:33

    You have the problem because df['Name'] contains both floats and strings AND df['Name'] is of type pandas.core.series.Series. This combination leads to an error with numpy.unique() as seen from traceback. You can fix the problem with 2 ways.

    tukey = pairwise_tukeyhsd(endog=df['Score'].astype('float'),
                              groups=list(df['Name']),  # list instead of a Series
                              alpha=0.05)
    

    OR

    Make sure df['Name'] contains only numbers or only strings.

    0 讨论(0)
提交回复
热议问题