Skip to content

REF: add skeleton for strategy pattern in describe #39298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

ivanovmg
Copy link
Member

@ivanovmg ivanovmg commented Jan 20, 2021

Added a skeleton for the strategy pattern in pandas/core/describe.py.
Currently the methods describe simply delegate to the corresponding describe_ functions.
In the next steps I plan on moving the describe functions into each of the strategy classes.
Finally, these functions can be unified, since a lot there has a common pattern.

@jreback
Copy link
Contributor

jreback commented Jan 20, 2021

Added a skeleton for the strategy pattern in pandas/core/describe.py.
Currently the methods describe simply delegate to the corresponding describe_ functions.
In the next steps I plan on moving the describe functions into each of the strategy classes.
Finally, these functions can be unified, since a lot there has a common pattern.

can you not unify these w/o using this pattern? this looks like a lot of extra boilerplate

@ivanovmg
Copy link
Member Author

can you not unify these w/o using this pattern? this looks like a lot of extra boilerplate

It is possible, but I imagine may not be an improvement over the current state.

The idea was to make an abstract strategy with the method describe like this

def describe(self):
    return Series(
        self.array,
        index=self.names,
        name=self.data.name,
        dtype=self.dtype,
    )

and then only re-define self.array, self.names and self.dtype in each of the concrete strategy classes.
This way it will probably be more readable and maintainable.
Please let me know what you think.

Currently the code is heading somewhat close to xref #36833.
If you consider that this is a wrong direction, then I am OK on closing this PR.

@jreback
Copy link
Contributor

jreback commented Jan 20, 2021

yeah the code looks pretty good as is. i am not sure we need to greatly expand it.

@ivanovmg
Copy link
Member Author

I am closing this as it was decided not to proceed with such type of refactoring.

@ivanovmg ivanovmg closed this Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants