lundi 8 juin 2020

problem in using "For" & "If" in Dataframes (Python)

i'm having a problem with dealing with for & if statement combined, when using the same concept on lists like the following

A = [1,2,3,4,5,6]
B = [3,6]

for item in A:
  if item not in B:
     print(item)

the output here will be logical which is (1,2,4,5)

My problem is in the following code down below

AD_Neighborhood = AD_Areas['Area'] # (Bigger list)
AD_Neigh_Coffee = AD_grouped['Neighborhood'] # (Smaller List) 

AD_No_Coffee=[]
for Area in AD_Neighborhood:
    if Area not in AD_Neigh_Coffee:
        AD_No_Coffee.append(Area)

the output is showing all values AD_Neighborhood instead of returning values that are not in the Smaller list.

Can someone please help me with this issue

Aucun commentaire:

Enregistrer un commentaire