'>' not supported between instances of 'str' and 'int'

后端 未结 5 1677
忘掉有多难
忘掉有多难 2021-01-13 16:02

I encountered the error

\'>\' not supported between instances of \'str\' and \'int\'

while trying to print the below lines in P

5条回答
  •  情歌与酒
    2021-01-13 16:19

    This is because values in 'text' column are of type str and you are comparing str with int. You can do a quick check for getting type of 'text' column.

    print(type(survey_df_clean['text'][:1][0]))
    

    For comparing you can do as following

    survey_df_clean[survey_df_clean['text'].astype(int)>30]
    

提交回复
热议问题