我使用python2.7和dask,并试图从远程机器查询db表到dask dataframe
表中有一个多列索引,我尝试使用以下脚本读取它
ddf = dd.read_sql_table("table name", "mysql://user:pass@ip:port/Dbname",spesific column name).head()并获得以下错误
start = asanyarray(start) * 1.0 TypeError: ufunc 'multiply‘不包含带有签名匹配类型dtype('S32')的循环 dtype('S32') dtype('S32')
我得到了解释这里的sqlalchemy
我不知道问题是什么,当我尝试用另一列查询作为索引,并且只使用ddf head()时,我不会得到一个错误,当我试图计算整个ddf时我得到了相同的错误,我假设这是一个关于列不是唯一值的问题,我没有一个列索引,而是多个列,在这里读取整个表的解决方案是什么?
谢谢。
全回溯
> Traceback (most recent call last): File "path", line 28, in <module>
> ddf = dd.read_sql_table("tablename", "mysql://user:pass@ip:port/dbname","indexcolumn") File "file", line
> 123, in read_sql_table
> divisions = np.linspace(mini, maxi, npartitions + 1).tolist() File
> "/home/user/.local/lib/python2.7/site-packages/numpy/core/function_base.py",
> line 108, in linspace
> start = asanyarray(start) * 1.0 TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('S32')
> dtype('S32') dtype('S32')发布于 2017-11-30 22:39:54
对于不提供更多信息或只指定分区数目的情况,read_sql_table中的分区逻辑只适用于数字,因为我们需要一种在最小值和最大值之间进行有序划分的方法。
显然,但是查询(获取最大值/分钟)返回了本例中的一个字符串。read_sql_table仍然可以工作,但是您将需要定义要在自己身上拆分的部门,并为它们提供divisions关键字,例如,
ddf = dd.read_sql_table("table name", "mysql://user:pass@ip:port/Dbname",
'index_col', divisions=['aardvark', 'llama', 'tapir', 'zebra']).head()或者,所讨论的字符串看起来肯定是一个数字,因此您可能需要更新表的架构,以确保它被解释为数字。
https://stackoverflow.com/questions/47573519
复制相似问题