original_docstring: Write entity data to disk.
  
      Args:
          entity (Entity) : Instance of :class:`.Entity`.
          path (str) : Location on disk to write entity data.
          format (str) : Format to use for writing entity data. Defaults to csv.
          kwargs (keywords) : Additional keyword arguments to pass as keywords arguments to the underlying serialization method.
  
      Returns:
          loading_info (dict) : Information on storage location and format of entity data.
      
docstring: Write entity data to disk.
docstring_tokens: Write entity data to disk .
code: def write_entity_data(entity, path, format='csv', **kwargs):
      '''Write entity data to disk.
  
      Args:
          entity (Entity) : Instance of :class:`.Entity`.
          path (str) : Location on disk to write entity data.
          format (str) : Format to use for writing entity data. Defaults to csv.
          kwargs (keywords) : Additional keyword arguments to pass as keywords arguments to the underlying serialization method.
  
      Returns:
          loading_info (dict) : Information on storage location and format of entity data.
      '''
      format = format.lower()
      basename = '.'.join([entity.id, format])
      location = os.path.join('data', basename)
      file = os.path.join(path, location)
      if format == 'csv':
          entity.df.to_csv(
              file,
              index=kwargs['index'],
              sep=kwargs['sep'],
              encoding=kwargs['encoding'],
              compression=kwargs['compression'],
          )
      elif format == 'parquet':
          # Serializing to parquet format raises an error when columns contain tuples.
          # Columns containing tuples are mapped as dtype object.
          # Issue is resolved by casting columns of dtype object to string.
          columns = entity.df.select_dtypes('object').columns
          entity.df[columns] = entity.df[columns].astype('unicode')
          entity.df.columns = entity.df.columns.astype('unicode')  # ensures string column names for python 2.7
          entity.df.to_parquet(file, **kwargs)
      elif format == 'pickle':
          entity.df.to_pickle(file, **kwargs)
      else:
          error = 'must be one of the following formats: {}'
          raise ValueError(error.format(', '.join(FORMATS)))
      return {'location': location, 'type': format, 'params': kwargs}
code_tokens: def write_entity_data ( entity , path , format = 'csv' , ** kwargs ) : format = format . lower ( ) basename = '.' . join ( [ entity . id , format ] ) location = os . path . join ( 'data' , basename ) file = os . path . join ( path , location ) if format == 'csv' : entity . df . to_csv ( file , index = kwargs [ 'index' ] , sep = kwargs [ 'sep' ] , encoding = kwargs [ 'encoding' ] , compression = kwargs [ 'compression' ] , ) elif format == 'parquet' : columns = entity . df . select_dtypes ( 'object' ) . columns entity . df [ columns ] = entity . df [ columns ] . astype ( 'unicode' ) entity . df . columns = entity . df . columns . astype ( 'unicode' ) entity . df . to_parquet ( file , ** kwargs ) elif format == 'pickle' : entity . df . to_pickle ( file , ** kwargs ) else : error = 'must be one of the following formats: {}' raise ValueError ( error . format ( ', ' . join ( FORMATS ) ) ) return { 'location' : location , 'type' : format , 'params' : kwargs }
short_docstring: Write entity data to disk.
short_docstring_tokens: Write entity data to disk .
comment: '''Write entity data to disk.
  
      Args:
          entity (Entity) : Instance of :class:`.Entity`.
          path (str) : Location on disk to write entity data.
          format (str) : Format to use for writing entity data. Defaults to csv.
          kwargs (keywords) : Additional keyword arguments to pass as keywords arguments to the underlying serialization method.
  
      Returns:
          loading_info (dict) : Information on storage location and format of entity data.
      '''$SEP$# Serializing to parquet format raises an error when columns contain tuples.$SEP$# Columns containing tuples are mapped as dtype object.$SEP$# Issue is resolved by casting columns of dtype object to string.$SEP$# ensures string column names for python 2.7