Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Example pandas.read_hfd5()

def iMain():
    """
    Read an hdf file generated by us to make sure
    we can recover its content and structure.
    Give the name of an hdf5 file as a command-line argument.
    """
    assert sys.argv, __doc__
    sFile = sys.argv[1]
    assert os.path.isfile(sFile)
    oHdfStore = pandas.HDFStore(sFile, mode='r')
    print oHdfStore.groups()
    # bug - no return value
    # oSignals = pandas.read_hdf(oHdfStore, '/servings/signals')
    mSignals = oHdfStore.select('/recipe/servings/mSignals', auto_close=False)    
    print mSignals
    print oHdfStore.get_node('/recipe')._v_attrs.metadata[0]['sUrl'] 
Comment

Examples pandas.read_hfd5()

def load_hdf5_data(file_path, **kwargs):
    key = kwargs.get('key', None)
    pandas_format = kwargs.get('pandas_format', True)
    mode = kwargs.get('mode', 'r')
    logger.info("Opening HDF5 file {} to read...".format(file_path))
    try:
        if pandas_format:
            data = pd.read_hdf(file_path, key=key, mode=mode)
        else:
            with h5py.File(file_path, mode) as f:
                data = f[key][()]
    except KeyError as e:
        logger.exception("Dataset {} does not exist".format(dataset))
        raise exceptions.FileLoadError("Dataset does not exist")
    except Exception as e:
        logger.exception("Problem loading dataset: {0}".format(e))
        raise exceptions.FileLoadError
    logger.info("Successfully loaded HDF5 data")
    return data 
Comment

PREVIOUS NEXT
Code Example
Python :: Find Factors of a Number Using for Loop 
Python :: Code Example of Comparing None with None type 
Python :: matplotlib insert small subplot into subplot 
Python :: Python String count() Implementation of the count() method using optional parameters 
Python :: Handling errors while using os.makedirs() method 
Python :: Math Module atan() Function in python 
Python :: int to floats 
Python :: pandas check if string has only spaces 
Python :: glom safely interact with dictionary 
Python :: python 3.9 32 bit 
Python :: python replace every space, dash and parentheses into underscore 
Python :: lambda2 criterion python 
Python :: to iterate across information on same nest 
Python :: python is x string methods 
Python :: grab element based on text from html page in python 
Python :: Python NumPy atleast_1d Function Example 
Python :: fuck you 
Python :: data framing with Pandas 
Python :: Python NumPy block Function Example by using np.eye function 
Python :: verbose field names 
Python :: Stacked or grouped bar char python 
Python :: django ejemplo de un formulario crud 
Python :: get forex exchange rates in python 
Python :: WAP to input 3 no.s and print their sum. 
Python :: # find all text files in directory or any type of files in directory 
Python :: tkintre sub windows 
Python :: knn compute_distances_one_loop 
Python :: List change after copy Python 
Python :: selsearch 
Python :: how to show type of a variable 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =