Changed .unique().shape[0] to .nunique()#810
Open
sursu wants to merge 1 commit intoCamDavidsonPilon:masterfrom
Open
Changed .unique().shape[0] to .nunique()#810sursu wants to merge 1 commit intoCamDavidsonPilon:masterfrom
sursu wants to merge 1 commit intoCamDavidsonPilon:masterfrom
Conversation
|
|
||
| self._n_examples = df.shape[0] | ||
| self._n_unique = df.index.unique().shape[0] | ||
| self._n_unique = df.index.nunique() |
Owner
There was a problem hiding this comment.
cool, TIL about this feature
Owner
|
There are unit test errors, and I think they caused by us carrying a multi-index around which just happens to have the (possibly redundant) id col - all comes full circle. Let me tie this into the issue #809, and once I decide on that topic, then this PR can be addressed. |
Author
|
The issue with MultiIndex comes from pandas apparently: In JupyterLab if I run: arrays = [[1, 1, 1, 2], ['red', 'blue', 'red', 'blue']]
mi = pd.MultiIndex.from_arrays(arrays, names=('number', 'color'))
mi.nunique()I get the following error: /opt/anaconda3/lib/python3.7/site-packages/pandas/core/dtypes/missing.py in _isna_new(obj)
131 # hack (for now) because MI registers as ndarray
132 elif isinstance(obj, ABCMultiIndex):
--> 133 raise NotImplementedError("isna is not defined for MultiIndex")
134 elif isinstance(
135 obj,
NotImplementedError: isna is not defined for MultiIndexThe comment there says it all. I guess this PR can be closed. |
Owner
|
I'd like to keep it open, if you don't mind. It's a reminder to address this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've recently learned how to do PRs.
So, here's a tiny change I'm proposing.