I am starting to learn SFrames data structure lately. I wonder if anyone experienced the problem of converting a "str" column to "float" or "int" column. In R, I could easily accomplish the task by as.numeric() or as.integer().
How could I do that in SFrames (python)?
Thanks,
I've found this approach works.
sf['column_name'] = sf['column_name'].astype(float)
sf['column_name'] = sf['column_name'].astype(str)
This doesn't work sometimes specially for empty columns. Its better to assign first to either string or float and then load elements. Example
sf['column'] = "" #for string
sf['column1'] = numpy.nan #for float
and then load values. I got struck in similar situation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.