首页 > 解决方案 > How is literal_eval() here is helping to fix the error?

问题描述

I have a pandas dataframe, which has a column called location, it has geo coordinates and the dtype is object as seen below.

enter image description here

I would like to use the values (as below) in this column to calculate the distance but I get the error as str cannot be accepted, only number type

enter image description here

But when literal_eval function is applied (as in first screenshot) on the column, I am able to calculate the distance between the coordinates.

enter image description here

I would like to understand what did literal_eval do to fix this error.

标签: python

解决方案


推荐阅读