Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 59 additions & 190 deletions notebooks/10-Read HDF5 Files with Pandas.ipynb

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions notebooks/3-Creating-and-Saving Data in HDF5 Files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 1,
"metadata": {
"collapsed": true
},
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 2,
"metadata": {
"collapsed": false
},
Expand All @@ -26,16 +26,25 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"with h5py.File('/home/noureddin/Desktop/hdf5_data.h5', 'w') as hdf:\n",
"with h5py.File('hdf5_data.h5', 'w') as hdf:\n",
" hdf.create_dataset('dataset1', data=matrix1)\n",
" hdf.create_dataset('dataset2', data=matrix2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -55,7 +64,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.0"
}
},
"nbformat": 4,
Expand Down
46 changes: 23 additions & 23 deletions notebooks/4-Reading Data from HDF5 Files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 2,
"metadata": {
"collapsed": true
},
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 3,
"metadata": {
"collapsed": false
},
Expand All @@ -31,7 +31,7 @@
}
],
"source": [
"with h5py.File('/home/noureddin/Desktop/hdf5_data.h5','r') as hdf:\n",
"with h5py.File('hdf5_data.h5','r') as hdf:\n",
" ls = list(hdf.keys())\n",
" print('List of datasets in this file: \\n', ls)\n",
" data = hdf.get('dataset2')\n",
Expand All @@ -41,30 +41,30 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 0.86222109, 0.81552981, 0.72947893, ..., 0.8151176 ,\n",
" 0.04256893, 0.20956778],\n",
" [ 0.00223081, 0.33763078, 0.16629403, ..., 0.69963576,\n",
" 0.69310324, 0.77839365],\n",
" [ 0.50803133, 0.88046107, 0.49747202, ..., 0.3320066 ,\n",
" 0.75703668, 0.76684165],\n",
"array([[ 0.66956872, 0.28030814, 0.4792187 , ..., 0.30348151,\n",
" 0.24023435, 0.68310023],\n",
" [ 0.90639203, 0.29122778, 0.98622719, ..., 0.42119197,\n",
" 0.9156541 , 0.39235254],\n",
" [ 0.11785202, 0.47731064, 0.07724071, ..., 0.42268917,\n",
" 0.60948362, 0.7063518 ],\n",
" ..., \n",
" [ 0.96940166, 0.28428291, 0.67076274, ..., 0.79801501,\n",
" 0.20872818, 0.28581377],\n",
" [ 0.1356297 , 0.4816769 , 0.08350457, ..., 0.26126381,\n",
" 0.83913621, 0.94482347],\n",
" [ 0.2145087 , 0.21925072, 0.88852823, ..., 0.13799023,\n",
" 0.35711444, 0.97585676]])"
" [ 0.92022095, 0.75778266, 0.01065805, ..., 0.81640267,\n",
" 0.39107846, 0.4930664 ],\n",
" [ 0.11697892, 0.22992495, 0.93729896, ..., 0.51983461,\n",
" 0.52039854, 0.20982922],\n",
" [ 0.15066775, 0.93379293, 0.0358572 , ..., 0.49265581,\n",
" 0.6233502 , 0.40890147]])"
]
},
"execution_count": 48,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -75,20 +75,20 @@
},
{
"cell_type": "code",
"execution_count": 49,
"execution_count": 6,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"f = h5py.File('/home/noureddin/Desktop/hdf5_data.h5', 'r')\n",
"f = h5py.File('hdf5_data.h5', 'r')\n",
"ls = list(f.keys())\n",
"f.close()"
]
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 7,
"metadata": {
"collapsed": false
},
Expand All @@ -99,7 +99,7 @@
"['dataset1', 'dataset2']"
]
},
"execution_count": 50,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -153,7 +153,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.0"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions notebooks/5-Creating Groups in HDF5 Files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 1,
"metadata": {
"collapsed": true
},
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 2,
"metadata": {
"collapsed": true
},
Expand All @@ -28,13 +28,13 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"with h5py.File('/home/noureddin/Desktop/hdf5_groups.h5', 'w') as hdf:\n",
"with h5py.File('hdf5_groups.h5', 'w') as hdf:\n",
" G1 = hdf.create_group('Group1')\n",
" G1.create_dataset('dataset1', data = matrix1)\n",
" G1.create_dataset('dataset4', data = matrix4)\n",
Expand Down Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.0"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/6-Reading Groups in HDF5 Files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.0"
}
},
"nbformat": 4,
Expand Down
12 changes: 6 additions & 6 deletions notebooks/7-HDF5 Compress Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 1,
"metadata": {
"collapsed": true
},
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 3,
"metadata": {
"collapsed": true
},
Expand All @@ -28,13 +28,13 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 4,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"with h5py.File('/home/noureddin/Desktop/hdf5_groups_compressed.h5', 'w') as hdf:\n",
"with h5py.File('hdf5_groups_compressed.h5', 'w') as hdf:\n",
" G1 = hdf.create_group('Group1')\n",
" G1.create_dataset('dataset1', data = matrix1, compression=\"gzip\", compression_opts=9)\n",
" G1.create_dataset('dataset4', data = matrix4, compression=\"gzip\", compression_opts=9)\n",
Expand Down Expand Up @@ -73,7 +73,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.0"
}
},
"nbformat": 4,
Expand Down
14 changes: 7 additions & 7 deletions notebooks/8-HDF5 Attributes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 1,
"metadata": {
"collapsed": true
},
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 2,
"metadata": {
"collapsed": true
},
Expand All @@ -26,15 +26,15 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 3,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
"source": [
"# Create the HDF5 file\n",
"hdf = h5py.File('/home/noureddin/Desktop/test.h5', 'w')\n",
"hdf = h5py.File('test.h5', 'w')\n",
"\n",
"# Create the datasets\n",
"dataset1 = hdf.create_dataset('dataset1', data=matrix1)\n",
Expand All @@ -49,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 4,
"metadata": {
"collapsed": false
},
Expand All @@ -70,7 +70,7 @@
],
"source": [
"# Read the HDF5 file\n",
"hdf = h5py.File('/home/noureddin/Desktop/test.h5', 'r')\n",
"hdf = h5py.File('test.h5', 'r')\n",
"ls = list(hdf.keys())\n",
"print('List of datasets in this file: \\n', ls)\n",
"data = hdf.get('dataset1')\n",
Expand Down Expand Up @@ -122,7 +122,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.0"
}
},
"nbformat": 4,
Expand Down
16 changes: 8 additions & 8 deletions notebooks/9-Create HDF5 Files with Pandas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 68,
"execution_count": 2,
"metadata": {
"collapsed": true
},
Expand All @@ -13,14 +13,14 @@
},
{
"cell_type": "code",
"execution_count": 69,
"execution_count": 3,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"# creates (or opens in append mode) an hdf5 file\n",
"hdf = pd.HDFStore('/home/noureddin/Desktop/hdf5_pandas.h5')"
"hdf = pd.HDFStore('hdf5_pandas.h5')"
]
},
{
Expand All @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 71,
"execution_count": 4,
"metadata": {
"collapsed": false
},
Expand All @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 72,
"execution_count": 5,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -155,7 +155,7 @@
"8 Sydney 1st 61 72"
]
},
"execution_count": 72,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -222,7 +222,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.0"
}
},
"nbformat": 4,
Expand Down
Binary file added notebooks/hdf5_data.h5
Binary file not shown.
Binary file added notebooks/hdf5_groups.h5
Binary file not shown.
Binary file added notebooks/hdf5_groups_compressed.h5
Binary file not shown.
Empty file added notebooks/hdf5_pandas.h5
Empty file.
Binary file added notebooks/test.h5
Binary file not shown.