在Python 3.5和3.6环境之间创建DataShader聚合期间的TypeError

时间:2017-12-08 16:40:55

标签: python-3.x pandas typeerror datashader

我一直在使用python 3.6.X中的散景/数据分析器仪表板,在仪表板项目中开发一些额外的功能。当项目在3.5.2 Python环境中执行时,我在创建3.6.X执行中不存在的聚合期间遇到TypeError: data type not understood

agg = method(self.df[(self.df['time_position'] >= time_start) & (self.df['time_position'] <= time_end)
                                 | (self.df['time_position'].isnull())], x_field, y_field, ds.count_cat(agg_field))

x_fieldy_fieldfloat64 web-Mercator经度,来自Pandas DataFrame的纬度字段以及time_starttime_endfloat64值为DF['time_position']字段。

使用Canvas.line

方法进行简单测试
agg = method(self.df, x_field, y_field, ds.count_cat(agg_field))

删除df(DataFrame)索引请求会产生:

Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\IPython\core\interactiveshell.py", line 2910, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-c9d8810a25e0>", line 1, in <module>
    agg = method(self.df, x_field, y_field, ds.count_cat(agg_field))
  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\datashader\core.py", line 202, in line
    return bypixel(source, self, Line(x, y), agg)
  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\datashader\core.py", line 410, in bypixel
    dshape = dshape_from_pandas(src)
  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\datashader\utils.py", line 344, in dshape_from_pandas
    for k in df.columns])
  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\datashader\utils.py", line 344, in <listcomp>
    for k in df.columns])
  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\datashader\utils.py", line 334, in dshape_from_pandas_helper
    dshape = datashape.CType.from_numpy_dtype(col.dtype)
  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\datashape\coretypes.py", line 781, in from_numpy_dtype
    if np.issubdtype(dt, np.datetime64):
  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\TrendingAnalysis_GUI_python352\lib\site-packages\numpy\core\numerictypes.py", line 755, in issubdtype
    return issubclass(dtype(arg1).type, arg2)
TypeError: data type not understood

当我逐步完成所有这一切时,它看起来像是无法识别pandas数据系列的数据类型???任何帮助都将受到赞赏,希望以一种适用于3.5和3.6 Python环境的解决方案的形式。

相关环境: Python 3.5.2 DataShader 0.6.2dev3

0 个答案:

没有答案