I have a dataframe, DF of columns of data as such:
X Y Z DIST_1
0 309000 563250 0 681483125
1 309000 563300 0 679910525
2 309000 563350 0 678342925
Upon attempting to run math.sqrt on DIST_1 with the following
DF['DIST'] = math.sqrt(DF['DIST_1'])
I am getting
TypeError: cannot convert the series to <class 'float'>
I have tried running three separate functions, on the individual column and the entire DataFrame, to fix this problem:
DF['DIST_1'] = pd.to_numeric(DF['DIST_1'])
DF['DIST_1'] = (DF['DIST_1']).astype(float)
DF= DF.applymap(float)
Each of these appears to have the desired results of changing DIST_1 to a float. Here is the output after running
DF['DIST_1'] = (DF['DIST_1']).astype(float)
X Y Z DIST_1
0 309000 563250 0 681483125.0
1 309000 563300 0 679910525.0
2 309000 563350 0 678342925.0
Again I run
DF['DIST'] = math.sqrt(DF['DIST_1'])
but the result is again
TypeError: cannot convert the series to <class 'float'>
What is the error in my code or my approach?
DF['DIST_1']is this one a list ?