reset password
Author Message
steveshim
Posts: 6
Posted 23:49 Jan 29, 2016 |

I'm having issues getting the median values for the 2nd and 14th columns. When i check df.info(), they are listed as objects and so when I try to call the median() function on them, I receive the error: "could not convert string to float:?"

I tried then converting the data in the columns to a float, but then I get the error "'Series' objects are mutable, thus they cannot be hashed"

Is there something I need to do to have these values as floats? Is anyone else running into this problem?

steveshim
Posts: 6
Posted 00:05 Jan 30, 2016 |

I should probably mention this is for the csv file on csns directly at this link http://csns.calstatela.edu/download?fileId=5300303

khsu
Posts: 30
Posted 00:08 Jan 30, 2016 |

The reason why those columns are listed as objects is because they contain '?' values in them. The '?' values can not be converted into float, hence the reason why it is a column of Objects.

You can not call the median() function because it requires the column to be the type Float. You have to convert the '?' values into NaNs or null values. After converting them, you can either make a second attempt to have the database convert the Object column into Float. An alternative is to simply create a new column and declaring it Float. Then copy all values from the original column into it, as well as storing the '?' values as NaNs in the new column.