How can i change dtype from object to float64 in a column, using python?
That is because there is a comma between the value
Because a float cannot have a comma, you need to first replace the comma and then convert it into float
result[col] = result[col].str.replace(",","").astype(float)
I extracted some data from investing but columns values are all dtype = object, so i cant work with them...
how should i convert object to float?
(2558    6.678,08 2557    6.897,23 2556    7.095,95 2555    7.151,21 2554    7.093,34 ...    4       4.050,38 3       4.042,63 2       4.181,13 1       4.219,56 0       4.223,33 Name: Alta, Length: 2559, dtype: object)
What i want is :
2558   6678.08 2557    6897.23 2556    7095.95 2555    7151.21 2554    7093.34 ...    4       4050.38 3       4042.63 2       4181.13 1       4219.56 0       4223.33 Name: Alta, Length: 2559, dtype: float
Tried to use the a function which would replace , for .
def clean(x): x = x.replace(".", "").replace(",",".")
but it doesnt work cause dtype is object
Thanks!