日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

cpickle安装_Py之h5py:Python库之h5py库的简介、安装、使用方法详细攻略

發(fā)布時間:2025/3/19 python 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 cpickle安装_Py之h5py:Python库之h5py库的简介、安装、使用方法详细攻略 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Py之h5py:Python庫之h5py庫的簡介、安裝、使用方法詳細攻略

目錄

h5py的簡介

Websites

Installation

Reporting bugs

h5py的安裝

h5py的使用方法

1、寫入數(shù)據(jù)

2、讀取數(shù)據(jù)


h5py的簡介

使用h5py庫讀寫超過內存的大數(shù)據(jù) 。在簡單數(shù)據(jù)的讀操作中,我們通常一次性把數(shù)據(jù)全部讀入到內存中。讀寫超過內存的大數(shù)據(jù)時,有別于簡單數(shù)據(jù)的讀寫操作,受限于內存大小,通常需要指定位置、指定區(qū)域讀寫操作,避免無關數(shù)據(jù)的讀寫。 h5py庫剛好可以實現(xiàn)這一功能。
h5py的優(yōu)勢:速度快、壓縮效率高,總之,numpy.savez和cPickle存儲work或不work的都可以試一試h5py!h5py文件是存放兩類對象的容器,數(shù)據(jù)集(dataset)和組(group),dataset類似數(shù)組類的數(shù)據(jù)集合,和numpy的數(shù)組差不多。group是像文件夾一樣的容器,它好比python中的字典,有鍵(key)和值(value)。group中可以存放dataset或者其他的group。”鍵”就是組成員的名稱,”值”就是組成員對象本身(組或者數(shù)據(jù)集),下面來看下如何創(chuàng)建組和數(shù)據(jù)集。

相關文章:HDF5 for Python

h5py is a thin, pythonic wrapper around the HDF5, which runs on Python 3 (3.6+).

Websites

  • Main website: https://www.h5py.org
  • Source code: https://github.com/h5py/h5py
  • Mailing list: https://groups.google.com/d/forum/h5py

Installation

Pre-build h5py can either be installed via your Python Distribution (e.g. Continuum Anaconda, Enthought Canopy) or from PyPI via pip. h5py is also distributed in many Linux Distributions (e.g. Ubuntu, Fedora), and in the MacOS package managers Homebrew, Macports, or Fink.

More detailed installation instructions, including how to install h5py with MPI support, can be found at: https://docs.h5py.org/en/latest/build.html.

Reporting bugs

Open a bug at https://github.com/h5py/h5py/issues. For general questions, ask on the list (https://groups.google.com/d/forum/h5py).

h5py的安裝

pip install h5py

?

安裝成功!哈哈,繼續(xù)學習去啦!

h5py的使用方法

后期更新……

1、寫入數(shù)據(jù)

import h5py"""create_dataset : 新建 datasetcreate_group : 新建 group """x = np.arange(100)with h5py.File('test.h5','w') as f:f.create_dataset('test_numpy',data=x)subgroup = f.create_group('subgroup')subgroup.create_dataset('test_numpy',data=x)subsub = subgroup.create_group('subsub')subsub.create_dataset('test_numpy',data=x)

2、讀取數(shù)據(jù)

"""keys() : 獲取本文件夾下所有的文件及文件夾的名字f['key_name'] : 獲取對應的對象 """ def read_data(filename):with h5py.File(filename,'r') as f:def print_name(name):print(name)f.visit(print_name)print('---------------------------------------')subgroup = f['subgroup'] print(subgroup.keys())print('---------------------------------------')dset = f['test_numpy']print(dset)print(dset.name)print(dset.shape)print(dset.dtype)print(dset[:])print('---------------------------------------')read_data('test.h5')

參考文章
h5py 必知--String存儲

總結

以上是生活随笔為你收集整理的cpickle安装_Py之h5py:Python库之h5py库的简介、安装、使用方法详细攻略的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。