Import csv as float

0

Good morning!

I have the following problem, I'm importing a base for python, but I can not manipulate it (average), because it's like str, I need to import all the values to come as float.

data = pd.read_csv ('C: \ path \ df.csv', index_col = 0, dtype = np.float64)

I used the following syntax to import, he shows me a mistake in the last column, saying he can not convert, could you help me? I have already tried to transform the data frame after importing it using np.float64 (date), but the same becomes array, then all functions stop working.

    
asked by anonymous 07.07.2018 / 14:48

1 answer

0

Assuming these str can be converted to float , you can use pd.to_numeric ():

df = pd.DataFrame([['1.', '2.'], ['3.', '4.']])
df = df.apply(pd.to_numeric)
    
07.07.2018 / 21:08