python - 读取h5数据集python的一部分
问题描述
我正在从 .h5 文件中读取大量数据(每个数据集 200,000 个点),我目前不需要所有这些数据,所以我一直在做的是读取数据,然后截断它。
有没有办法只读取 h5 数据集的前 X 项?
解决方案
Use this...
import numpy as np
import h5py
filename = 'file.hdf5'
f = h5py.File(filename, 'r')
key = list(f.keys())[0]
data = list(f[key][1])
Indexing may vary for key
and f[key]
, where [0]
is an arbitrary dataset of file.hdf5
and [1]
is just an arbitrary column I grabbed.
推荐阅读
- javascript - 如何读取带有空格的对象的属性名称
- javascript - 列出 Firebase 存储对象会省略所有元数据
- python - 如何创建一个简单的函数来使用 matplot.lib 在 Python 中绘制数据?
- api - 如何在 Axios 发布请求中为布尔值设置 formData
- javascript - Vercel 与 AWS 不工作:“部署失败,没有给出监控 URL”
- r - geom_dotplot 填充美学变化数据分组
- javascript - JavaScript slice() 在本地与使用 Github 站点的在线工作方式不同
- python - 无法按下列表/字典中的 tkinter 按钮
- javascript - React - 在 setState 挂钩中更新数组
- ruby-on-rails - Rails 6中的分离日志