Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove the pd.DataFrame and pd.Series extension methods #368

@jorenham

Description

@jorenham

Currently, if pandas is installed, import lmo automatically registers the dataframe- and series accessors (pandas docs). There are several major issues with this approach:

  • It significantly slows down import lmo if pandas is installed, even if the user doesn't import pandas. If I remember correctly from a benchmark I did a while back, this is responsible for the majority of the runtime of an (initial) import lmo call.
  • It's impossible to statically type: Static type-checkers cannot "be told" that pd.DataFrame and pd.Series actually have the l_* methods, let alone their exact signatures. The only workaround is to manually cast the dataframe or series instances to lmo.contrib.pandas.{DataFrame,Pandas}, which is very annoying.
  • There are better alternatives:
    • Series.l_{}(...) just calls lmo.l_{}(_, ...) on the instance, and in the "plural" cases, rewraps it as a Series with a new "r" index. Once Support __array_ufunc__ in lmo.l_(loc|scale|variation|skew|kurtosis)  #184 is implemented, this could (for the most part) also be done with a simple lmo.l_{}, which is a better alternative.
    • DataFrame.l_{}(...) is basically an alias for DataFrame.apply(lmo.l_{}, ...), so almost as easy to do it manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeBackwards incompatiblecontribIntegration with 3rd party packages

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions