The problem is that i want to replace the values in the origin and dest columns in the df flights with the values from the dictionary airports but error is give cannot replace object with string. But the object dtype is equal to string right?
I looked for answers, people said it can be done manually but this is very hectic and other said i am using replace wrongly and i can use it like this but i don't understand how replace({'Keyword': {x:'other' for x in y}}, inplace=True)
airports=pd.read_csv('airports.csv')
airport_dict=pd.Series(airports.city.values,index=airports.iata).to_dict()
flights.Origin.replace(airport_dict.keys(), airport_dict.values(), inplace =True)
flights.Dest.replace(airport_dict.keys(), airport_dict.values(), inplace = True)
Values from csv file :
iata airport
00M Thigpen
00R Livingston Municipal
00V Meadow Lake
Values from Origin DF:
00M
00V
and so on i want to replace them with the full names