- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个数据帧,df1
存储在 pd.HDFStore
对象中,另一个要附加到数据帧。
store = pd.HDFStore('dataframe_store.h5')
df1 = pd.DataFrame(np.empty((100, 5)))
df2 = pd.DataFrame(np.empty((100, 5)))
store['df1'] = df1
实际上,我希望最终结果等于...
store['df1'] = df1.append(df2)
我想将 df2
附加到存储的 df1
,而不是用新数据帧完全覆盖 HDFStore
对象。这可能吗?
此外,当我运行以下代码时,我返回 ValueError can only append to Tables
...这是为什么?
df = pd.DataFrame(np.empty((1000, 5)))
df2 = pd.DataFrame(np.empty((1000, 5)))
store = pd.HDFStore('store.h5')
store['df'] = df
store.append('df', df2)
最佳答案
根据 the docs (我的重点):
HDFStore supports another PyTables format on disk, the table format. Conceptually a table is shaped very much like a DataFrame, with rows and columns. A table may be appended to in the same or other sessions. In addition, delete & query type operations are supported. This format is specified by format='table' or format='t' to append or put or to_hdf
New in version 0.13.
This format can be set as an option as well pd.set_option('io.hdf.default_format','table') to enable put/append/to_hdf to by default store in the table format.
In [361]: store = pd.HDFStore('store.h5')
In [362]: df1 = df[0:4]
In [363]: df2 = df[4:]
# append data (creates a table automatically)
In [364]: store.append('df', df1)
In [365]: store.append('df', df2)
In [366]: store
Out[366]:
<class 'pandas.io.pytables.HDFStore'>
File path: store.h5
# select the entire object
In [367]: store.select('df')
Out[367]:
A B C
2000-01-01 0.887163 0.859588 -0.636524
2000-01-02 0.015696 -2.242685 1.150036
2000-01-03 0.991946 0.953324 -2.021255
2000-01-04 -0.334077 0.002118 0.405453
2000-01-05 0.289092 1.321158 -1.546906
2000-01-06 -0.202646 -0.655969 0.193421
2000-01-07 0.553439 1.318152 -0.469305
2000-01-08 0.675554 -1.817027 -0.183109
# the type of stored data
In [368]: store.root.df._v_attrs.pandas_type
Out[368]: 'frame_table'
Note: You can also create a table by passing format='table' or format='t' to a put operation.
关于python - HDFStore 更新存储的 HDF5 python pandas 数据帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44986027/
只是想知道我对组/数据集名称的自由程度如何,或者是否需要使名称简短(因此可读性较差)。这适用于包含许多具有许多重复名称的组和数据集的 HDF5 文件。一些 XML API 做 string inter
简短问题 当 Pandas 在 HDFStore 上工作时(例如: .mean() 或 .apply() ),它是否将内存中的完整数据作为 DataFrame 加载,还是将记录作为 Serie 进行处
我有几个不同的相关数据框(如果需要,可以使用 id 加入它们)。但是,我并不总是同时需要它们。 由于它们非常大,将它们存储在单独的 HDF 存储中是否有意义?或者当我处理同一文件中的其他帧时,携带“未
我似乎无法让它发挥作用。所有示例和线程都让人创建新的数据集。我只想更新已创建的数据集中的一个字段。 这是我所拥有的: h5_file = h5py.File(event_file_path, "r+"
我在 hadoop 上写入小文件时遇到一个奇怪的问题。下面是示例程序 public void writeFile(Configuration conf, String message, String
当我运行 hdf namenode -format 时,它想要删除目录 /home/hadoop/hadooptmpdata/dfs/name/current 但它没有权限执行此操作。如何授予它权限?
有没有办法使用 pandas HDF 存储获取 HDF 表的信息? 例如在 SQL 中有: SELECT COUNT(*) 我想阅读基本表格大小而不必自己加载表格。 最佳答案 试试这个: In [4]
在 pandas 下,每次我使用表格格式而不是固定格式时,我的内存消耗都会爆炸。 import numpy as np np.random.seed(seed=10) df = pd.DataFram
我正在处理大量数据集,每个数据集都是一个 pandas DataFrame,由于它们的大小,我需要从磁盘访问它们。从我读到的内容来看,HDF 似乎是与它们一起工作的好方法,但我对构建数据的最佳方法有点
我正在开发云服务器,我需要使用 blob 存储来存储 HDF 文件 ( http://www.hdfgroup.org/HDF5/ )。 与文件中的创建、读取、写入和修改数据元素相关的函数来自 HDF
我正在尝试将数据存储为 hdf 格式,并希望将默认数据类型设置为表,以便稍后查询。 我正在使用基本代码: import pandas as pd from numpy import random as
我最近在 Lubuntu 上安装了 Anacondas Python。 我正在尝试加载可在 Windows PC 上运行的 HDF 文件: In [14]: import pandas as pd I
我写了下面的脚本,但是我有一个内存消耗的问题,pandas 分配了超过 30 G 的内存,其中数据文件的总和大约是 18 G import pandas as pd import numpy as n
您好,我看到了一些以 HDF5 格式存储的科学数据,我想知道是否有任何 NoSQl 解决方案可以达到与 HDF5 相同的读/写性能。 我的示例的数据使用树结构(/root 然后/root/key 然后
我想知道如何获取 hdf 文件的列名(似乎存储在 hdf header 中);例如,一个文件可能有名为 [a,b,c,d] 的列,而另一个文件有 [a,b,c] 列,而另一个文件有 [b,e,r,z]
我想做什么? pd.read_csv(... nrows=###) 可以读取文件的前 n 行。我想在使用 pd.read_hdf(...) 时做同样的事情。 问题是什么? 我对 documentati
我想将数千张动物图像加载到 pandas df 中,添加特征并可能转换为 HDF。 我使用 cv2.imread() 尝试了以下方法 import cv2 import os import numpy
我想知道 HDF 套件中嵌入的 kafka 和 Confluence 套件中嵌入的 kafka 之间的差异,特别是模式注册工具。 最佳答案 https://registry-project.readt
我想知道 HDF 套件中嵌入的 kafka 和 Confluence 套件中嵌入的 kafka 之间的差异,特别是模式注册工具。 最佳答案 https://registry-project.readt
我使用 pandas 和 hdf5 文件来处理大量数据(例如 10GB 或更多)。我想使用表格格式,以便在读取数据时能够有效地查询数据。但是,当我想将数据写入 hdf 存储时(使用 DataFrame
我是一名优秀的程序员,十分优秀!