What is the proper Way to document a pandas dataframe accessor with sphinx?

Viewed 118

My library adds a namespace to all pandas Dataframes using the pandas extension api:

    import pandas as pd
    def extend_pandas():
        @pd.api.extensions.register_dataframe_accessor("my_namespace")
        class CsAccessor:
            def __init__(self, pandas_obj):
                self._obj = pd.DataFrame()
                self._my_attr = "some attribute"


            @property
            def my_attr(self):
                """
                I want my_attr in my documentation
                """
                return self._my_attr
            
        
            def my_method(self):
                """
                And this also
                """
                return f" this is a method from {self._obj}.namespace"

extend_pandas_df() is called when my library is loaded. I am using sphinx to generate my documentation. I am tying to find a good way to document the methods and properties of that namespace. It seems pandas is using the autosummary extension to document its accessors. So far, I couldnot figure out how to do that.

0 Answers
Related