【发布时间】:2018-05-14 09:15:55
【问题描述】:
我正在使用带有 dask 的 python 2.7 并尝试从远程机器查询 db 表到 dask 数据帧
我在表中有一个多列索引,我尝试使用以下脚本读取它
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' did not contain a loop with signature matching types dtype('S32')dtype('S32') dtype('S32')
我得到了 here 解释的 sqlalchemy uri
我不确定是什么问题,当我尝试通过另一列作为索引进行查询并且仅使用 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')
【问题讨论】:
-
你能验证等效的 pandas 操作是否有效吗?
-
请显示更详细的回溯,并在错误发生时运行调试以查找
start的值。 -
@MRocklin 与熊猫配合得很好
-
@mdurant start 的值为 {str}'-1000001542'
-
看起来你看到了一个应该是数字的字符串
标签: python mysql dataframe sqlalchemy dask