-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC/API: Discussion on whether __finalize__ is public #33338
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
Comments
To be clear, I only meant to say "those So for clarity, before your PR to add def __finalize__(self, other, method=None, **kwargs):
"""propagate metadata from other to self """
# merge operation: using metadata of the left object
if method == "merge":
for name in self._metadata:
object.__setattr__(self, name, getattr(other.left, name, None))
# concat operation: using metadata of the first object
elif method == "concat":
for name in self._metadata:
object.__setattr__(self, name, getattr(other.objs[0], name, None))
else:
for name in self._metadata:
object.__setattr__(self, name, getattr(other, name, None))
return self To repeat what I said on the PR: I always assumed this is part of our sublcassing API. Although it is actually not documented in our subclassing docs. But probably since geopandas has always been using that, I assumed it be part of the sublcassing API. That said, the "API" is quite brittle though. If you look at the GeoPandas snippet above, you will see that for "concat" it gets the For new APIs, if we decide to go through with finalize methods and regard this as public, we should maybe try to rationalize what object is passed. For example, for something like "concat", it could also have been a list of dataframe objects, instead of the |
Making this more robust is my main goal of any refactor. The current status of |
Currently
NDFrame.__finalize__
is not documented. We only have a couple references to it in the whatsnew.I have a few questions around its API
self.__finalize__()
?method='...'
considered public?The text was updated successfully, but these errors were encountered: