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 :: change folder icon with python 
Python :: geopandas rename column 
Python :: python get bits from byte 
Python :: how to use return python 
Python :: Python Program to Shuffle Deck of Cards 
Python :: convert utm to decimal degrees python 
Python :: how to parse http request in python 
Python :: swapping 
Python :: python binary tree search 
Python :: symmetric_difference() Function of sets in python 
Python :: difference between 2 dataframes 
Python :: What are Augmented Assignment Operators in python 
Python :: How to take n space separated Integer in a list in python? 
Python :: how does tkinter iconify() function work in python 
Python :: python running mean pandas 
Python :: Python NumPy stack Function Example with 2d array 
Python :: aiohttps 
Python :: Total processing python 
Python :: string remove suffix python 
Python :: clipboard python 
Python :: how to iterate through a list of numbers in python 
Python :: pyspark drop 
Python :: standard deviation in python without numpy 
Python :: parse xml in python 
Python :: pandas replace word begins with contains 
Python :: python string upper method 
Python :: pandas read parquet from s3 
Python :: django add queury parameters to reverse 
Python :: python basics flask project 
Python :: select statement python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =