I'm trying to analyze a database with coordinates (X,Y). I need to read each data in that column and classify it as either North or South if it's "Y" or East or West if it's "X". So basically what I want to do is read each data in that column and apply one of those values depending on the coordinate X and Y.
my df is something like this (it's and xlsx doc but ill try to make something alike)
df = [(0,23),(1,22),(4,39),(3,15)] #so i want to read each coordinate and if X is in a range between 0-23 say its East and if Y is in a range between 28-40 say its North.
I've tried to apply a function to the entire column and later adding a new column to the dataframe with the result from the previous function, I may have the idea but I don't know how to make it.
listing = list(0,23)
def calle():
if calle in listing:
return Oeste #This is the code I tried to make a function with just one of the values
#So basically if the the coordinate is in that range(0-23) I want it to be west
df1["Comienza calle"] = df1["Comienza calle"].apply(calle)
print(df1) #This is how i tried to apply the previous function
#And my idea is to add a new column with the result from that function
df1.insert(2, "Ubicación comienzo", ["Noroeste","Noreste","Suroeste","Sureste"], True)
print(df1)