reset password
Author Message
rkmx52
Posts: 23
Posted 20:32 Feb 02, 2016 |

The y values (the Cmb MPG column) are read into Pandas as Strings because some y values have a slash in them (i.e. row 15, 25/57).

 

How should we deal with these values if we want to convert the y column into a numeric column?

 

msargent
Posts: 519
Posted 20:34 Feb 02, 2016 |

Take the average of the two values. Use python string methods to split the string around the '/'. You may need to play around with this to get it to work. One way is to write a separate function that takes in a string like this and transforms it to the average. Once you do this to all those split values, Pandas should automatically convert the column to a numeric type. 

Last edited by msargent at 21:19 Feb 02, 2016.