I have a data frame with columns:
pd.DataFrame({'col':[[-74.61286283, 40.56889437], [nan, nan], [-105.18943020000002, 40.07872419], [-96.83537306, 32.82099448]]})
This column is a longitude-latitude column, but I want to make it latitude-longitude. and swap their positions, so that I can use this along with another similar column to calculate distance using geopy. I tried this:
df['col'].apply(lambda x: [x[1], x[0]])
But it is giving me error: TypeError: 'float' object is not subscriptable I understand this is because of nan values, I also tried to replace nan with 0, but no luck. Then it gives error: TypeError: 'int' object is not subscriptable Please suggest.