Skip to content

Instantly share code, notes, and snippets.

@andreagrioni
Created May 14, 2021 21:48
Show Gist options
  • Save andreagrioni/404f7ea80a524e563f778526a00e9635 to your computer and use it in GitHub Desktop.
Save andreagrioni/404f7ea80a524e563f778526a00e9635 to your computer and use it in GitHub Desktop.
read h5 file
import h5py
import pandas as pd
# set path to h5 file
filepath = "h5_path"
# read HDF5 file
f = h5py.File(filepath, 'r')
# get each dataset and convert to pandas DataFrame
dset_x_train = pd.DataFrame(f['x_train'])
dset_y_train = pd.DataFrame(f['y_train'])
dset_x_test = pd.DataFrame(f['x_test'])
dset_y_test = pd.DataFrame(f['y_test'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment