问题标签 [hdfstore]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1128 浏览

python - Python/Pandas HDF5 NameError 问题

我写了两个脚本。

第一个脚本设计为只运行一次,并创建一个名为df_empty的大型空数据框,使用脚本中的以下代码将其保存到 HDF5 文件storage.h5中:

这完美地工作。

我的下一个脚本设计为每 30 分钟运行一次,并从每半小时生成的 CSV 文件中获取数据,并且:

  1. 将此数据放入新的数据框df

  2. 将storage.h5中的数据框导入为df2

  3. 使用 index union 命令将dfdf2合并到df3中;

  4. 将新的数据帧保存回storage.h5,有效地覆盖以前的文件。

相关部分代码如下:

如果我在 Jupyter Notebook 中按顺序运行这两个脚本(我已经安装了最新版本的 Anaconda 并在 Windows 7 机器上运行它),这将很有效。

但是,当我从命令提示符运行时,我遇到了问题。第一个脚本运行没有错误。但是,第二个脚本会引发以下错误:

回溯(最后一次调用):文件“myfile.py”,第 64 行,在 hdf.put('d1', df3, format='table', data_columns=True) NameError: name 'hdf' is not defined 关闭剩余打开文件:storage.h5...donestorage.h5...done

有人对我可能做错了什么有任何建议吗?

0 投票
1 回答
404 浏览

pandas - Numexpr/PyTables:如何从列表/数组传递执行多个条件查询?

我正在使用 PyTables 进行查询(即根据某些条件选择多行),其中包含函数tables.Table.read()tables.Table.read_where(). 这本质上是基于 numpy 和带有 NumExpr 的 pandas:

http://www.pytables.org/usersguide/tutorials.html http://www.pytables.org/cookbook/hints_for_sql_users.html https://github.com/PyTables/PyTables/blob/6782047b9223897fd59ff4967d71d7fdfb474f16/tables/table。 py

在“sql 用户提示”中,一次选择多行的示例是这样的:

假设我更喜欢如下查询:所有等于温度 100 或等于温度 90 的行

这完美地工作。但我想通过“温度值”列表/数组来完成这项任务。

这可能吗?我的想法是我会编写一个函数,让用户输入要查询的值列表,并为每个值执行 OR 查询。

0 投票
1 回答
4820 浏览

python - ImportError:HDFStore 需要 PyTables,“没有名为表的模块”

我从这里遵循了安装指南。http://www.pytables.org/usersguide/installation.html

因此,每当我从 PyTables/build/lib.linux-x86_64-2.7 文件夹在 iPython 中运行此命令时,它都可以正常工作。

In [1]: import pandas as pd

In [2]: store = pd.HDFStore('store.h5')

但是每当我从其他文件夹运行相同的命令时,它都会给我指定的错误。是 PYTHONPATH 问题吗?如果是,如何解决?

0 投票
0 回答
63 浏览

python - Pandas HDFStore 查询返回最大日期

我有一个大型数据集(>100M 行),我已将其放入 HDF 存储中,以便使用 Pandas 进行分析。它太大了,无法全部容纳在内存中。我希望能够setup在数据集的字段中选择具有最大或最小日期时间值的行。

所以,类似于

如果整个数据集都在内存中。有什么建议么?

0 投票
1 回答
108 浏览

python - 在具有内存限制的 Python 2.7 中解析具有两种不同行格式的大型 CSV 文件?

我有一组需要在 Python 2.7 中读取的文件(一个 ~10GB 文件分成多个文件,因此每个文件约 1GB)。文件格式是这样的:

以 开头的行2可以无限重复以获得唯一LINEINDEX#值,然后下一行将以1KEY项目开头(随后是它自己的行2,依此类推)。我需要能够有效地生成2基于多个KEYs 的数据类型表,所以我实际上根本不需要行1。空字段中可能有也可能没有数据,所以我需要捕获那里的所有内容。

围绕这些数据的大多数程序都使用 Pandas,所以我理想情况下试图坚持这一点。我的计划是将这些文件解析为 HDF5 文件,并根据需要从中创建表。我不确定这是否是解决手头问题的最佳方法,因此欢迎任何有关替代方案的建议。目前,此处理是通过 ffdf 在 R 中完成的,但必须将其移至 Python。

我无法逐行读取这些文件(几乎立即弹出内存不足)来删除/忽略行1。我尝试read_csv使用Pandascomment='1'将这些行视为“注释”并忽略它们,但我得到了 CParserError,这似乎比基于其他帖子的任何内容都更像一个错误(我尝试跳过第一行,因为其他人建议该错误,但它没有起到作用)。

如果我在没有指定数据类型(我有)的情况下处理文件,我会遇到性能问题,例如:

然后,在转换时to_hdf,类似的性能问题:

什么是最好的方法来忽略以 all-together 开头的行1,或者以某种方式指定两个不同的 dType 映射,而不会耗尽内存,每次我尝试逐行工作时都会发生这种情况?2有没有更好的方法来存储此数据以根据 s 列表查询行项目KEY

现在,代码很简单:

0 投票
0 回答
397 浏览

python - Determine the number of chunks in the selection from an hdf5 file

When selecting from an hdf5 file in chunks, I would like to know how many chunks there are in the resulting selection.

Number of rows in the input data nrows can be up to 100mln, chunksize is 100k, but for most selections the number of rows in a chunk nrows_chunk is smaller, so for different where I can have selections with one or many chunks. Before doing operations with chunks and at the time of calling iteratorGenerator() I would like to know how many chunks there will be. Intuitively, I want something like len(list(enumerate(iteratorGenerator()))) in my syntax, but this would give length=1 (I suppose because only one chunk at a time is considered by iteratorGenerator()).

I suspected there is no solution to this issue as the whole idea of using generator is not to perform all selections at once but do it chunk by chunk. But actually, when I run the for loop below, the very first iteration takes really long, but the following iterations take just a seconds, which suggests that on the first iteration most of the data about chunks is collected. This is puzzling to me and I would appreciate any explanation on how selection by chunks works.

Moreover, I am not sure what the chunksize in HDFStore.select refers to. From my experience, it is a maximal size of the selected chunk after applying where condition. On the other hand, http://pandas.pydata.org/pandas-docs/stable/generated/pandas.HDFStore.select.html defines chunksize: nrows to include in iteration, which to me sounds like the number of rows to read from. Which is correct?

0 投票
1 回答
293 浏览

python - 从python中的.h5文件获取帧时出现Unicode错误

我正在尝试使用 pandas.HDFStore 读取 .h5 文件

使用此代码:

它有效,尝试这行代码时会出现问题

它返回此错误:

“UnicodeDecodeError:‘ascii’编解码器无法解码位置 2108 中的字节 0xc3:序数不在范围内 (128)”

我尝试了此链接中的解决方案,但它也不起作用。

所以请帮我解决这个错误。

0 投票
0 回答
476 浏览

pandas - pandas HDFStore 的限制

我打算使用 Pandas HDFStore 作为核心 csv 操作的临时文件。

(csv --> HDFStore --> Pandas 中的核心操作)。

就是想 :

  • HDF5 的大小限制,可在 1 台机器上实际使用(不是理论上的......)

  • 数据透视表的操作成本(100 列,固定 VARCHAR,数字)。

  • 我是否需要切换到 Postgres(将 csv 加载到 Postgres)和数据库的东西......

试图在谷歌上找到 HDF5 的一些基准限制大小与计算时间,但找不到任何东西。

csv 的总大小约为 500Go - 1To(未压缩)。

0 投票
1 回答
901 浏览

python - 具有按索引值选择多索引的 Pandas HDFStore 未找到列

我有一个存储在 HDF5 文件中的大型 Pandas 数据框。Dataframe 是具有 Datetime 和 PatientID 的多索引。

但是按患者 ID 过滤 Select 语句不起作用。

我收到这个错误

任何帮助深表感谢。我不确定这是否可能是一个错误,因为我一直在阅读应该可以按索引查询。

0 投票
1 回答
1322 浏览

hadoop - 如何将 HDF5 文件转换为 Parquet 文件?

我通过 pandas 将大约 800 GB 的巨大数据帧存储到 HDF5 中pandas.HDFStore()

我想用 Impala 查询这个。有没有一种直接的方法可以将这些数据解析成 Parquet?或者 Impala 是否允许您直接使用 HDF5?HDF5上的数据还有另一种选择吗?