python 2.7 - pandas DataFrame metadata and set_index -


after several hours of writing nice metadata handler pandas dataframe, this:

>>> import pandas pd >>> = pd.dataframe({'frame':[0,1,2,3,4,5,6,7], 'x':[1,2,2,2,3,4,2,11], 'y':[2,2,3,2,2,3,2,10]}) >>>    frame   x   y 0      0   1   2 1      1   2   2 2      2   2   3 3      3   2   2 4      4   3   2 5      5   4   3 6      6   2   2 7      7  11  10  >>> a.set_index('frame')         x   y frame         0       1   2 1       2   2 2       2   3 3       2   2 4       3   2 5       4   3 6       2   2 7      11  10  >>> type(a._metadata) list  >>> a._metadata.append(dict())  >>> a.set_index('frame') --------------------------------------------------------------------------- typeerror                                 traceback (most recent call last) <ipython-input-11-a271477b5f41> in <module>() ----> 1 a.set_index('frame')  /usr/lib/python2.7/dist-packages/pandas/core/frame.pyc in set_index(self, keys, drop, append, inplace, verify_integrity)    2453             frame = self    2454         else: -> 2455             frame = self.copy()    2456     2457         arrays = []  /usr/lib/python2.7/dist-packages/pandas/core/generic.pyc in copy(self, deep)    2212         """    2213         data = self._data.copy(deep=deep) -> 2214         return self._constructor(data).__finalize__(self)    2215     2216     def convert_objects(self, convert_dates=true, convert_numeric=false,  /usr/lib/python2.7/dist-packages/pandas/core/generic.pyc in __finalize__(self, other, method, **kwargs)    1923         if isinstance(other, ndframe):    1924             name in self._metadata: -> 1925                 object.__setattr__(self, name, getattr(other, name, none))    1926         return self    1927   typeerror: getattr(): attribute name must string 

appending dictionary might not ultimate way , changed

>>> a._metadata = dict() 

but, shouldn't be, or yes? bug or mistake?

thanks, kami


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -