Skip to content

Conversation

@mariuszlitwin
Copy link
Collaborator

This PR adds DataFrame accessors as a first-class functionality in Picatrix.

Accessors can now be added in a following way:

from picatrix import new_accessor_namespace

accessor = new_accessor_namespace("example")

@accessor.add_accessor(validator: lambda df: "email" in df.columns)
def bulk_email(df, send_as_bcc = False):
  ...

And later used as following if the validator matches the content of a DataFrame:

df.example.bulk_email(send_as_bcc=True)

I also used the opportunity to clean up the configuration a little as many libraries and tools dropped support for Python 3.7 since the last PR.

mariuszlitwin and others added 6 commits February 24, 2023 11:24
Accessors are part of pandas API - https://pandas.pydata.org/docs/development/extending.html.
They allow to extend DataFrames with new funcionalities. API proposed
by pandas is based on classes and isn't easily extendable. The one I am
proposing here is more function-centric, compact and allows for easy
extension of already existing accessor namespaces. See tests for
details.
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.

1 participant