On Mon, Nov 5, 2012 at 10:08 AM, Adam Hughes <
hughes...@gmail.com> wrote:
>
> I actually posted the same discussion a while ago.
>
> I've written a few modules to let you transfer attributes (not instance methods yet) between dataframes. Something like:
>
> df1=DataFrame()
> df1.metadata="kilometers"
>
> df2=df1.ix[0:40]
>
> transfer_attributes(df1, df2)
>
> print df2.metadata
Adam, thanks for the head's up. Your implementation is a bit too
complicated for my use case, I think. However, those links lead me to
realize that, unlike numpy arrays, you can add attributes to a
DataFrame on the fly, e.g.,
In [36]: x_arr = np.arange(6)
In [37]: x_arr.units = 'meters'
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-37-e2b027ca98ac> in <module>()
----> 1 x_arr.units = 'meters'
AttributeError: 'numpy.ndarray' object has no attribute 'units'
In [38]: x_df = pandas.DataFrame(x_arr)
In [39]: x_df.units = 'meters'
In [40]: print(x_df.units)
meters
Knowing this, my needs are currently met. Thanks again,
-paul