[英]Dask Getting Error converting timestamp column to datetime
I have a dask dataframe with thi structure:我有一个 dask dataframe 结构:
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:当我尝试添加一个名为 ds 的使用时间戳的新列时:
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? kk
是 dask object 吗? If so then it is not a valid number, and so float
won't know what to do with it.如果是这样,那么它不是一个有效的数字,因此float
将不知道如何处理它。
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.我怀疑您可能希望使用.apply
方法在您的系列中的所有行中应用普通的 Python function 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.