简体   繁体   中英

Dask Getting Error converting timestamp column to datetime

I have a dask dataframe with thi structure:

Dask DataFrame Structure:
               timestamp      bid    offer     high      low mid_open   change change_pct market_delay market_state update_time
npartitions=76                                                                                                                 
                 float64  float64  float64  float64  float64  float64  float64    float64       object       object      object
                     
Dask Name: read-csv, 76 tasks

When I try to add a new columen called ds that uses the timestamp:

import pytz

tz = pytz.timezone('Europe/London')

kk['ds'] = datetime.datetime.fromtimestamp(float(kk.timestamp), tz)

I get the error:

TypeError: Series.__float__ returned non-float (type function)

Is kk a dask object? If so then it is not a valid number, and so float won't know what to do with it.

I suspect that you may instead want to use the .apply method to apply a normal Python function across all of the rows in your series.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM