[Python] PANDAS pd.read_hdf works with some, but not all tables in my HDF5 file

Discussão em 'Python' iniciado por Stack, Abril 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Pandas in Python 3.7 in order to read data from a HDF5 file. The HDF5 file contains tables of results from MSC Nastran.

    The HDF5 file is named 'ave_01.h5'

    The HDF5 table of displacements looks like this:

    [​IMG]

    Using the following works just fine:

    import numpy as np
    import pandas as pd
    pd.read_hdf('./ave_01.h5', 'NASTRAN/RESULT/NODAL/DISPLACEMENT')


    However, I have another table for stress results, which looks like this:

    [​IMG]

    So I would expect the following code to work, but it does not:

    pd.read_hdf('./ave_01.h5', '/NASTRAN/RESULT/ELEMENTAL/STRESS/QUAD_CN')


    I receive the following error:


    ValueError: Wrong number of items passed 5, placement implies 1
    ​

    I have noticed that this second table contains lists in some columns, whereas the first table does not. These lists also contain 5 elements. Perhaps this is causing the error, but I don't know if this is true, nor how to correct for this.

    Where am I going wrong?

    Thanks.

    For reference, these results are of a simple test model, as can be seen below: [​IMG]

    Continue reading...

Compartilhe esta Página