wanna to read hdf file in dataframe

gss = pd.read_hdf('gss.hdf5', 'gs') this the code i have used on VS code. and i got this

Traceback (most recent call last):
  File "d:\pthon_txt\", line 4, in <module>
    gss = pd.read_hdf('gss.hdf5', 'gs')
  File "C:\Users\Mohammed\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\", line 442, in read_hdf
  File "C:\Users\Mohammed\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\", line 847, in select
    raise KeyError(f"No object named {key} in the file")
KeyError: 'No object named gs in the file'
PS D:\pthon_txt> 

i wanna to load this hdf file in pandas data frame


  • The error is saying that the key gs doesn't exist in the file. If there's only one key you can use read_hdf without the key parameter, eg :

    df = pd.read_hdf('gss.hdf5')