-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
PERF: SparseDataFrame._init_dict uses intermediary dict, not DataFrame #16883
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e785961
PERF: SparseDataFrame._init_dict uses intermediary dict, not DataFrame
kernc caf3a36
add whatsnew entry
kernc 31d9b28
fixup! PERF: SparseDataFrame._init_dict uses intermediary dict, not D…
kernc b55b1a2
fixup! PERF: SparseDataFrame._init_dict uses intermediary dict, not D…
kernc 7053de5
fixup! PERF: SparseDataFrame._init_dict uses intermediary dict, not D…
kernc 83d8140
xfail one more test
kernc e0b468f
fixup! xfail one more test
kernc f41b490
add asv benchmarks
kernc 0a98ac9
fixup! add whatsnew entry
kernc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
PERF: SparseDataFrame._init_dict uses intermediary dict, not DataFrame
- Loading branch information
commit e785961c2d81c8b8224a5784a87339f00f9c0971
There are no files selected for viewing
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
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.
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.
use isnull
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 had wrongly assumed raw numpy was, as is often the case, faster.
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.
no, why do you need this at all?
Uh oh!
There was an error while loading. Please reload this page.
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.
Because one of the tests (
test_nan_columnname
, #8822) apparently sets afloat('nan')
(is not np.nan
) as a valid column name, and{float('nan'): 'foo'}[np.nan]
is a KeyError. I didn't know what else to do. DataFrame apparently handles all cases of nan specially; it seemed easiest to force singleton for dict.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.
have a look thru how DataFrame handles this in the init_dict routines
don't want to be reinventing the wheel here
Uh oh!
There was an error while loading. Please reload this page.
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.
Incorrectly in the sense that:
Nans are tricky because it generally holds
nan != nan
. But I guess more often than not, this leads to confusion when nan is expected to be a single, catch-all bin.How can I improve on the above singleton approach?
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 point to the test that is failing. I don't want to address this in this PR. This is non-trivial and needs to be common code. ok with xfailing those tests (and making an issue)
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.
The existing failing test for sparse is
pandas.tests.sparse.test_frame.TestSparseDataFrame.test_nan_columnname
.Issue #8822 has some discussion.
nan
in indexes are supported and have valid uses (e.g. #3729).So xfailing that test in this PR ...