Python TypeError: cannot convert the series to when trying to do math on dataframe

后端 未结 3 2082
长情又很酷
长情又很酷 2020-12-10 02:45

I have a data frame that looks something like this:

defaultdict(, {\'XYF\':             TimeUS           GyrX           GyrY                    


        
相关标签:
3条回答
  • 2020-12-10 03:00

    What if you do this (as was suggested earlier):

    new_time = dfs['XYF']['TimeUS'].astype(float)
    new_time_F = new_time / 1000000
    
    0 讨论(0)
  • 2020-12-10 03:10

    Seems your initial data contains strings and not numbers. It would probably be best to ensure that the data is already of the required type up front.

    However, you can convert strings to numbers like this:

    pd.Series(['123', '42']).astype(float)
    

    instead of float(series)

    0 讨论(0)
  • 2020-12-10 03:14

    You can use from the pd.to_numeric(s)

    0 讨论(0)
提交回复
热议问题