0

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)
user170302
  • 21
  • 1
  • related? https://stackoverflow.com/questions/39584118/dask-dataframe-how-to-convert-column-to-to-datetime ...or this: https://stackoverflow.com/q/51420042/10197418 – FObersteiner Aug 06 '20 at 14:47
  • Thanks @MrFuppes but its not really related. trying to first of all work out what the error is saying. Also cant use the to_datetime functionality of dask. Its design for string representations of time; we have Unix time and want to convert that – user170302 Aug 07 '20 at 08:01

1 Answers1

1

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.

MRocklin
  • 55,641
  • 23
  • 163
  • 235