-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: Add MultiIndex subclass. #596
Conversation
bigframes/core/indexes/base.py
Outdated
|
||
def __init__( | ||
# Overrided on __new__ to create subclasses like python does | ||
def __new__( | ||
self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__new__ is a static method that takes cls as param instead of self.
Sorry, something went wrong.
All reactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
All reactions
@@ -454,24 +475,27 @@ def __len__(self): | |||
return self.shape[0] | |||
|
|||
|
|||
# Index that mutates the originating dataframe/series | |||
class FrameIndex(Index): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be a breaking change that we may not want to introduce right now. @tswast
Sorry, something went wrong.
All reactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am deleting a class yes, but it was more of an implementation detail of the Index class. Should only affect users if they were somehow depending on exact type or type name in their code, which would be very strange.
Sorry, something went wrong.
All reactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @GarrettWu.
Given that we say ) -> Index:
in the only method that would return such an object and we don't explicitly document FrameIndex
, I'm okay overlooking this and treating FrameIndex
as a private implementation detail.
Sorry, something went wrong.
All reactions
bigframes/core/indexes/base.py
Outdated
self, | ||
data=None, | ||
dtype=None, | ||
*, | ||
name=None, | ||
session=None, | ||
linked_frame: Union[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it an internal only param or part of the public API? If internal, we may want to make it only in a private constructor. If public API, then should update the docs.
Looks like pandas doesn't have it.
Sorry, something went wrong.
All reactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for internal purposes only. Removed from constructor, now directly set the property after initialized.
Sorry, something went wrong.
All reactions
@@ -454,24 +475,27 @@ def __len__(self): | |||
return self.shape[0] | |||
|
|||
|
|||
# Index that mutates the originating dataframe/series | |||
class FrameIndex(Index): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @GarrettWu.
Given that we say ) -> Index:
in the only method that would return such an object and we don't explicitly document FrameIndex
, I'm okay overlooking this and treating FrameIndex
as a private implementation detail.
Sorry, something went wrong.
All reactions
bigframes/core/indexes/base.py
Outdated
): | ||
super().__init__(series_or_dataframe._block) | ||
self._whole_frame = series_or_dataframe | ||
class MultiIndex(Index, vendored_pandas_multindex.MultiIndex): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As much as possible, I'd like our module hierarch to reflect pandas. In pandas, this is defined in pandas/core/indexes/multi.py
. Anything under core
is considered private-ish, but these paths do leak out in some of the pandas docs.
Let's make a bigframes/core/indexes/multi.py
file and put this there.
Sorry, something went wrong.
All reactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Sorry, something went wrong.
All reactions
Successfully merging this pull request may close these issues.
None yet
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕