-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pivot & unstack with nan in the index #9061
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
Conversation
benchmarks with
|
This is not an area of the pandas codebase that I'm particularly familiar with, but I took a quick look and generally this looks good to me. |
89d3473
to
11fdd46
Compare
@behzadnouri could you add release notes for this enhancement? A simple example like the one you show in your first post would be nice. @hayd @TomAugspurger @sinhrks any thoughts? |
# when index includes `nan`, need to lift levels/strides by 1 | ||
self.lift = 1 if -1 in self.index.labels[self.level] else 0 | ||
|
||
self.new_index_levels = list(index.levels) |
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.
perhaps use .copy() here rather than list. ?
This looks pretty good to me too (pesky NaN). |
Yes, looks nice. |
11fdd46
to
06b0431
Compare
@shoyer added the release notes. I put this under bug fixes, since it is fixing a special case where an existing api breaks, as opposed to adding a new feature. Since there was some re-factoring with #9101 I reran the benchmarks:
|
""" | ||
Given a list of labels at each level, returns a flat array of int64 ids | ||
corresponding to unique tuples across the labels. If `retain_lex_rank`, | ||
rank of returned ids preserve lexical ranks of labels. |
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.
can you add a Parameters/Returns
block
7a53d97
to
489a04a
Compare
489a04a
to
e3afd5b
Compare
pivot & unstack with nan in the index
thanks what I am referring above is that then these types of structures are easy to create and very tricky to actually index.
This fails
This is ok though
|
closes #7466
on branch:
the
pivot
function requires theunstack
function to work withnan
s in the index:the
4th
and5th
column are so that it is easy to verify the frame:nan
values are kept out of levels and are handled by labels: