0

I want to get rows of dataFrame if value in some column is in the list of acceptable values. So I'm trying to get series of bool values first to use them for dataframe indexing.

I'm getting ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). Why is that and how can I solve my task?

c = ['m','n','a']
df = pd.DataFrame({'c':c})
df['c'] == 'm'                    #works
df['c'] in ['m','x']              #valueError!
df['c'] == 'm' or df['c'] == 'x'  #same error! Why?
Dork
  • 1,816
  • 9
  • 29
  • 57

0 Answers0