Lon_X Lat_Y
5,234234 6,3234234
5,234234 6,3234234
5,234234 6,3234234
5,234234 6,3234234
5,234234 6,3234234
我在上面的熊貓/數據框中有GPS座標。然而,這些使用逗號分隔符。使用熊貓將這些轉換爲浮動GPS座標的最佳方法是什麼?替換數據幀中的值Python
for item in frame.Lon_X:
float(item.replace(",", ".")) # makes the conversion but does not store it back
我已經試過iteritems功能,但似乎很慢,給我一個警告,我真的不明白:
for index, value in frame.Lon_X.iteritems():
frame.Lon_X[index] = float(value.replace(",", "."))
見警告文檔中: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy 從ipykernel進口kernelapp爲app