我正在尝试将cassandra数据库中的数据加载到Dask数据框中。我尝试查询以下内容没有成功:
query="""SELECT * FROM document_table"""
df = man.session.execute(query)
df = dd.DataFrame(list(df))
TypeError Traceback (most recent call last)
<ipython-input-135-021507f6f2ab> in <module>()
----> 1 a = dd.DataFrame(list(df))
TypeError: __init__() missing 3 required positional arguments: 'name', 'meta', and 'divisions'
有人知道一种简单的方法将数据直接从Cassandra加载到Dask吗?太多的内存太重了,首先会加载到熊猫中。
答案 0 :(得分:1)
您的代码存在一些问题:
行import { Component } from '@angular/core';
@Component({
selector: 'page-home',
template: `
<ion-header>
<ion-navbar>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<h2>Welcome to Ionic!</h2>
<ion-row>
<ion-col col-6>
<ion-label>
Using the custom component:
</ion-label>
</ion-col>
<ion-col col-2 *ngFor="let button of buttons">
<custom-button
[clear]="button.clear ? true : null"
[outline]="button.outline ? true : null"
[name]="button.name"
(customClick)="onClicked()">
</custom-button>
</ion-col>
</ion-row>
</ion-content>
`
})
export class HomePage {
public buttons: Array<any> = [
{ clear: true, outline: false, name: 'Clear' },
{ clear: false, outline: true, name: 'Outline' },
{ clear: false, outline: false, name: 'Default' }
];
public onClicked() {
console.log('Clicked!');
}
}
可能会将整个数据集加载到内存中。在此不调用Dask,在此不起作用。知道Cassandra驱动程序的人可以确认这一点。
df =
生成数据框的列名称列表,并删除所有数据
list(df)
,如果您阅读的docs不是这样构造的。
您可能想要做的是:a)创建一个返回数据分区的函数,b)延迟此函数并使用分区的各种值进行调用c)使用dd.DataFrame
来创建dask数据帧。例如,假设该表具有字段dd.from_delayed
,该字段方便地具有可能的值1..6,并且每个分区的行数相似:
partfield