pypet/storageservice.py
def _prm_write_pandas_data(self, key, data, group, fullname, flag, **kwargs):
        """Stores a pandas DataFrame into hdf5.

        :param key:

            Name of data item to store

        :param data:

            Pandas Data to Store

        :param group:

            Group node where to store data in hdf5 file

        :param fullname:

            Full name of the `data_to_store`s original container, only needed for throwing errors.

        :param flag:

            If it is a series, frame or panel

        """
        try:
            if 'filters' not in kwargs:
                filters = self._all_get_filters(kwargs)
                kwargs['filters'] = filters
            if 'format' not in kwargs:
                kwargs['format'] = self.pandas_format
            if 'encoding' not in kwargs:
                kwargs['encoding'] = self.encoding

            overwrite = kwargs.pop('overwrite', False)

            if key in group and not (overwrite or kwargs.get('append', False)):
                raise ValueError(
                    'DataFrame `%s` already exists in `%s`. '
                    'To append pass ``append=`True```.' % (key, fullname))
            else:
                self._logger.debug('Appending to pandas data `%s` in `%s`' % (key, fullname))

            if data is not None and (kwargs['format'] == 'f' or kwargs['format'] == 'fixed'):
                kwargs['expectedrows'] = data.shape[0]

            name = group._v_pathname + '/' + key
            self._hdf5store.put(name, data, **kwargs)
            self._hdf5store.flush()
            self._hdf5file.flush()

            frame_group = group._f_get_child(key)
            setattr(frame_group._v_attrs, HDF5StorageService.STORAGE_TYPE, flag)
            self._hdf5file.flush()

        except:
            self._logger.error('Failed storing pandas data `%s` of `%s`.' % (key, fullname))
            raise
def _prm_write_pandas_data(self, key, data, group, fullname, flag, **kwargs):
        try:
            if 'filters' not in kwargs:
                filters = self._all_get_filters(kwargs)
                kwargs['filters'] = filters
            if 'format' not in kwargs:
                kwargs['format'] = self.pandas_format
            if 'encoding' not in kwargs:
                kwargs['encoding'] = self.encoding

            overwrite = kwargs.pop('overwrite', False)

            if key in group and not (overwrite or kwargs.get('append', False)):
                raise ValueError(
                    'DataFrame `%s` already exists in `%s`. '
                    'To append pass ``append=`True```.' % (key, fullname))
            else:
                self._logger.debug('Appending to pandas data `%s` in `%s`' % (key, fullname))

            if data is not None and (kwargs['format'] == 'f' or kwargs['format'] == 'fixed'):
                kwargs['expectedrows'] = data.shape[0]

            name = group._v_pathname + '/' + key
            self._hdf5store.put(name, data, **kwargs)
            self._hdf5store.flush()
            self._hdf5file.flush()

            frame_group = group._f_get_child(key)
            setattr(frame_group._v_attrs, HDF5StorageService.STORAGE_TYPE, flag)
            self._hdf5file.flush()

        except:
            self._logger.error('Failed storing pandas data `%s` of `%s`.' % (key, fullname))
            raise
def _prm_write_pandas_data ( self , key , data , group , fullname , flag , * * kwargs ) : try : if 'filters' not in kwargs : filters = self . _all_get_filters ( kwargs ) kwargs [ 'filters' ] = filters if 'format' not in kwargs : kwargs [ 'format' ] = self . pandas_format if 'encoding' not in kwargs : kwargs [ 'encoding' ] = self . encoding overwrite = kwargs . pop ( 'overwrite' , False ) if key in group and not ( overwrite or kwargs . get ( 'append' , False ) ) : raise ValueError ( 'DataFrame `%s` already exists in `%s`. ' 'To append pass ``append=`True```.' % ( key , fullname ) ) else : self . _logger . debug ( 'Appending to pandas data `%s` in `%s`' % ( key , fullname ) ) if data is not None and ( kwargs [ 'format' ] == 'f' or kwargs [ 'format' ] == 'fixed' ) : kwargs [ 'expectedrows' ] = data . shape [ 0 ] name = group . _v_pathname + '/' + key self . _hdf5store . put ( name , data , * * kwargs ) self . _hdf5store . flush ( ) self . _hdf5file . flush ( ) frame_group = group . _f_get_child ( key ) setattr ( frame_group . _v_attrs , HDF5StorageService . STORAGE_TYPE , flag ) self . _hdf5file . flush ( ) except : self . _logger . error ( 'Failed storing pandas data `%s` of `%s`.' % ( key , fullname ) ) raise
Stores a pandas DataFrame into hdf5.

        :param key:

            Name of data item to store

        :param data:

            Pandas Data to Store

        :param group:

            Group node where to store data in hdf5 file

        :param fullname:

            Full name of the `data_to_store`s original container, only needed for throwing errors.

        :param flag:

            If it is a series, frame or panel
Stores a pandas DataFrame into hdf5 .