0

Why I constantly getting error:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

I tried a couple of things including bitwise operator. Snippet of the error section of the code below

for i in range(len(df_list)):
    df_list[i] = df_list[i].lower()
    
for item in df.index:
    d = df['StreetName'][item]
    if(d in df_list): 
    #if d in df_list or d in df_list2 :
        df.loc[item,'Clean_status_j'] = 'True'
        df.loc[item,'Clean_status'] = 'True'
    if (d in df_list2):
Henry Ecker
  • 31,792
  • 14
  • 29
  • 50
S.HUNT
  • 1
  • At some point _before_ this provided code you have unsafely subset your DataFrame. Either `new_df = df[cols]` or `new_df = df[mask]` when it should have been `new_df = df[cols].copy()` or `new_df = df[mask].copy()` The warning is letting you know that `df[mask]['col'] = value` may not work because `df[mask]` may produce a copy and recommends that you use `df.loc[mask, 'col'] = value` but that message is not clear here since you're doing something like `new_df = df[mask]` then later doing `new_df[col] = value` which looks to pandas like a (deferred) `df[mask][col] = value` call. – Henry Ecker May 02 '22 at 04:02

0 Answers0