【发布时间】:2020-08-20 12:03:00
【问题描述】:
我一直在努力创建一个包含数百万行的 csv 绘图。我正在尝试使用 vaex 模块,但我被卡住了..
import vaex
# converts and reads large csv into hdf5 format
df = vaex.open("mydir/cov2.csv", convert='hdf5')
df.head()
输出
# chr pos cov index
<i style='opacity: 0.6'>0</i> NC_024468.2 1.34986e+08 6 0
<i style='opacity: 0.6'>1</i> NC_024468.2 1.34986e+08 6 1
<i style='opacity: 0.6'>2</i> NC_024468.2 1.34986e+08 6 2
csv 被转换为 hdf5 并加载,但现在有 2 个索引,1 个带有奇怪的 HTML 格式。当我尝试像在documentation 中那样绘制它时,以及在此thread 中作为基准的解决方案:
df.plot_widget(df.pos, df.cov)
我得到一个值错误。
ValueError: <bound method DataFrame.cov of
# chr pos cov index
0 NC_024468.2 134986302 6 0
1 NC_024468.2 134986303 6 1
... ... ... ... ...
2,704,117 NC_024468.2 137690419 0 2704117
2,704,118 NC_024468.2 137690420 0 2704118 > is not of string or Expression type, but <class 'method'>
解决方案是更改为 df.col.cov 或 df["cov"]。不过,现在我从 plot_widget 方法得到一个空输出:
PlotTemplate(components={'main-widget': VBox(children=(VBox(children=(Figure(axes=[Axis(color='#666', grid_col…
Plot2dDefault(w=None, what='count(*)', x='pos', y='cov', z=None)
谁能帮帮我?
亲切的问候, 里卡多
编辑
csv 数据的样本。 pos 列每行增加 1(1.37 亿),cov 几乎总是 0,但在某些区域会达到 1-400:
chr,pos,cov
NC_024468.2,1,0
NC_024468.2,2,0
NC_024468.2,3,0
.....
NC_024468.2,137690418,7
NC_024468.2,137690419,6
NC_024468.2,137690420,6
【问题讨论】:
-
嗨,Ricardo,您介意添加您的数据样本吗?
-
嗨!我添加了一个示例。我在前 3 行和后 3 行之间放置了点。我现在实际上已经设法使用 plot 方法制作了一个绘图,但这仅适用于数据的一个子集,否则它会崩溃。
标签: python hdf5 large-data vaex