larry-discuss team mailing list archive
-
larry-discuss team
-
Mailing list archive
-
Message #00003
Re: New features: totuples, fromtuples
On Sun, Jan 31, 2010 at 11:17 AM, <josef.pktd@xxxxxxxxx> wrote:
> (first mail: not sure how well it works, since I cannot just reply to
> previous thread)
>
> I was trying to get a bit of an overview how fromxxx and toxxx work in
> pandas and tabular and scikits.statsmodels. It would be good to have
> methods or functions that make the conversion between different
> packages easier.
Yes, toxxx and fromxxx would be a good way to convert between packages.
> For example, the toDict method of pandas creates a hierarchical
> dictionary instead of tuple keys.
> The totuples looks close to structured arrays, so it might be possible
> to extend it to torecords, fromrecords. However, totuples creates a
> "long" format while structured arrays are 2d. pandas and, I think,
> also tabular allow to unflatten, convert long to wide, but for
> structured arrays a 2d table might be more convenient.
Record as in numpy record array?
> To method versus function: numpy and scikits.statsmodels use factory
> functions fromxxx, tabular and pandas use classmethods (I think). The
> latter is actually easier to find in the docs, since the list of
> methods shows both the fromxxx and the toxxx methods.
I agree on the docs. But I went with the toxxx as methods and fromxxx
as functions to be more like numpy. That would be easy to change just
by making fromxxx staticmethods. I did add "see also" sections which
in sphinx provides a link between toxxx and fromxxx.
References