Aug-25-2019, 02:45 PM
Hi
Trying to extract the core of the problem, I have found that a formula works for one row only, if another row is added, an error shows:
cannot convert the series to <class 'float'>
By the way, does not work even if the content is turned to float beforehand.
So here it is
What is the cause and how to work around that?
Thank you.
Trying to extract the core of the problem, I have found that a formula works for one row only, if another row is added, an error shows:
cannot convert the series to <class 'float'>
By the way, does not work even if the content is turned to float beforehand.
So here it is
import pandas as pd import numpy as np startlat=51.454234 startlon=-2.593225 df6 = pd.DataFrame(columns=['Latitude', 'Longitude']) df6.loc[0] = [51.3862652, -2.3638941] # df6.loc[1] = [51.3862652, -2.3638941] df6['dist1']=6371.01 * np.arccos(np.sin(np.radians(float(startlat)))*np.sin(np.radians(float(df6['Latitude']))) + np.cos(np.radians(float(startlat)))*np.cos(np.radians(float(df6['Latitude'])))*np.cos(np.radians(float(startlon)) - np.radians(float(df6['Longitude'])))) df6.head()This works. However, when I uncomment the addition of the second row and run this all again, python returns an error: TypeError: cannot convert the series to <class 'float'>
What is the cause and how to work around that?
Thank you.