Check if string is in a pandas dataframe

前端 未结 7 2069
北荒
北荒 2020-11-28 06:38

I would like to see if a particular string exists in a particular column within my dataframe.

I\'m getting the error

ValueError: The truth v

7条回答
  •  余生分开走
    2020-11-28 06:50

    Pandas seem to be recommending df.to_numpy since the other methods still raise a FutureWarning: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_numpy.html#pandas.DataFrame.to_numpy

    So, an alternative that would work int this case is:

    b=a['Names']
    c = b.to_numpy().tolist()
    if 'Mel' in c:
         print("Mel is in the dataframe column Names")
    

提交回复
热议问题