Warrior
Warrior

Reputation: 87

Issue converting Data frame datatype from object to float64

I need to convert the datatype of y_test from object to float64. I first converted into an array of strings ( In[54] ) and then to an array of floating point numbers (Inputs [83] & [85]) but it is not added to the y_test data frame.

y_test feature CO(ppm) is still displayed as object datatype ( Out[90] ).

Can someone please help me understand how to accomplish this? Thank you.

enter image description here

Upvotes: 0

Views: 69

Answers (1)

Ehsan
Ehsan

Reputation: 12397

Try:

y_test['CO'] = y_test.CO.apply(lambda x: x.replace(',','')).astype(float)

Upvotes: 1

Related Questions