Is it possible to access the pandas DataFrame
to which my accessor belongs, from within the accessor class?
Specifically, I would like to let a method in the accessor class assign a series to the main dataframe df
via df.myaccessor.calc_displacement()
which operates on columns x
and y
in df
.
Instead, the most I can access is the pandas DataFrame _obj
which is visible to the accessor. But updating _obj
does not update df
.
From within the accessor class from dir(self)
:
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_obj', '_validate']
Pandas version is 0.24.2.
After looking through public examples of accessors (eg, GeoAccessor
, .dt
), there do not appear to be built-in methods for this, unfortunately.