Commit 3e52dfd2 authored by Michele Maris's avatar Michele Maris
Browse files

u

parent 17daffc2
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -61,29 +61,44 @@ class AppendableDict :
      """
      for k in self._k :
         self._d[k]=np.concatenate(self._d[k])
   def to_arrayDict(self,flatten=False) :
   def to_arrayDict(self,flatten=False,skip=[]) :
      """ dictionary to numpy.array
          if flatten==True applies .flatten_nested_columns() method
      """
      if skip is None :
         _skip=[]
      elif(type(skip)==type('')) :
         _skip=[skip]
      else :
         _skip=skip
      _keys=[k for k in self.keys() if not k in _skip]
      #
      out=OrderedDict()
      if flatten :
         for k in self.keys() :
         for k in _keys :
            out[k]=np.concatenate(self[k])
      else :
         for k in self.keys() :
         for k in _keys :
            out[k]=np.array(self[k])
      return out
   def to_pandas(self,flatten=False,to_array=True) :
   def to_pandas(self,flatten=False,to_array=True,skip=[]) :
      """ dictionary to pandas.DataFrame
          if flatten==True applies .flatten_nested_columns() method
          if to_array==True converts colums to np.array before to perform conversion to pandas.DataFrame,
            if some column contains vectors instead of scalars to_array=False must be used otherways errors may occurs
      """
      if to_array :
         out=self.to_arrayDict(flatten=flatten)
         out=self.to_arrayDict(flatten=flatten,skip=skip)
      else :
         if skip is None :
            _skip=[]
         elif(type(skip)==type('')) :
            _skip=[skip]
         else :
            _skip=skip
         _keys=[k for k in self.keys() if not k in _skip]
         out = OrderedDict()
         for k in self.keys() :
         for k in _keys :
            out[k]=self[k]
      return pandas.DataFrame(out)
   def to_csv_slow(self,csvfile,justBody=False,creator="",index_label=None,sep=',',comment=None,addEnd=False,mode='w') :