CLN: series to now inherit from NDFrame by jreback · Pull Request #3482 · pandas-dev/pandas (original) (raw)

Major refactor primarily to make Series inherit from NDFrame

affects #4080, #3862, #816, #3217, #3386, #4463, #4204, #4118 , #4555

Preserves pickle compat
very few tests were changed (and only for compat on return objects)
a few performance enhancements, a couple of regressions (see bottom)

obviously this is a large change in terms of the codebase, but it brings more consistency between series/frame/panel (not all of this is there yet, but future changes are much easier)

Series is now like Frame in that it has a BlockManager (called SingleBlockManager), which holds a block (of any type we support). This introduced some overhead in doing certain operations, which I spent a lot of time optimizing away, further optimizations will come from cythonizing the core/internals, which should be straightforward at this point

Highlites below:

In 0.13.0 there is a major refactor primarily to subclass Series from NDFrame,
which is the base class currently for DataFrame and Panel, to unify methods
and behaviors. Series formerly subclassed directly from ndarray.

Perf changed a bit primarily in groupby where a Series has to be reconstructed in order to be passed to the function (in some cases). I basically pass a Series-like class to the grouped function to see if it doesn't raise, if its ok, then it is used rather than a full Series in order to reduce overhead of the Series creation for each group.

-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
groupby_multi_python                         | 109.3636 |  78.3370 |   1.3961 |
frame_iteritems                              |   3.4664 |   2.0154 |   1.7200 |
frame_fancy_lookup                           |   3.3991 |   1.6137 |   2.1064 |
sparse_frame_constructor                     |  11.7100 |   5.3363 |   2.1944 |
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------

Target [c5d9495] : BUG: fix ujson handling of new series object
Base   [1b91f4f] : BUG: Fixed non-unique indexing memory allocation issue with .ix/.loc (GH4280)