modin-project / modin

Modin: Scale your Pandas workflows by changing a single line of code
http://modin.readthedocs.io
Apache License 2.0
9.91k stars 653 forks source link

Using a custom pandas accessor with Modin #7281

Closed anaypat5 closed 6 months ago

anaypat5 commented 6 months ago

Hi, I was wondering if its possible to use custom pandas accessors with Modin. I have one set up, but when using Modin with Ray it will throw the error that DataFrame object has no attribute <accessor>. I am currently circumventing this issue by converting the Modin DataFrame to a base Pandas DataFrame, but I wanted to see if this is something that is already implemented, such that I don't have to convert my DataFrame every time I want to use the accessor, especially when the DataFrames are getting large. Thanks.

noloerino commented 6 months ago

Hi @anaypat5, are you trying to add a custom method on modin frames like these? https://pandas.pydata.org/docs/development/extending.html

You can do this in modin with modin.pandas.api.extensions.register_dataframe_accessor (which modifies modin.pandas.DataFrame), register_series_accessor (modifies modin.pandas.Series), and register_pd_accessor (modifies the top-level modin.pandas namespace). Please try it out and see if it works.

noloerino commented 6 months ago

@anaypat5 I'm marking this issue as closed for now--feel free to reopen or file a new one if you need further help.