-
Notifications
You must be signed in to change notification settings - Fork 94
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
make Table.to_dataframe
create real sparse frames
#809
Merged
Conversation
This file contains 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
This is great, thank you! In prior versions of pandas, we couldn't pass
scipy sparse objects. Do you know by chance if this effects our present
minimum version requirement?
…On Thu, Mar 7, 2019, 1:01 PM Christian Diener ***@***.***> wrote:
So this is a proposed fix to #808
<#808>. It basically
specifies the fill value for sparse data explicitly. I also added a test to
check for that in the future.
Before that the the matrix data was first converted to individual
pandas.SparseSeries and passed to pandas.SparseDataFrame. This is now
done directly without the intermediate allocations since SparseDataFrame
accepts any scipy sparse matrix. If Table.matrix_data can be something
else than a numpy matrix or scipy sparse matrix this might not work but for
now all tests seem to pass. Happy to change that back to the old behavior
if that was on purpose.
As a side effect to_dataframe is now much faster on large sparse data
sets. Takes about 20s on my machine for the American Gut biom (was more
than 30m before).
------------------------------
You can view, comment on, or merge this pull request online at:
#809
Commit Summary
- specify fill value
File Changes
- *M* biom/table.py
<https://github.com/biocore/biom-format/pull/809/files#diff-0> (9)
- *M* biom/tests/test_table.py
<https://github.com/biocore/biom-format/pull/809/files#diff-1> (9)
Patch Links:
- https://github.com/biocore/biom-format/pull/809.patch
- https://github.com/biocore/biom-format/pull/809.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#809>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAc8stS8w-kHIobrAjsICjk6qhYEqg97ks5vUX5DgaJpZM4bkGfk>
.
|
wasade
requested changes
Mar 7, 2019
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.
Code seems reasonable, able to add a mention to the ChangeLog by chance?
Was introduced in pandas 0.20.0, so should be fine with the current version requirement (>=0.20.0). |
Looks great! |
Thanks @cdiener and @ElDeveloper! |
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.
So this is a proposed fix to #808. It basically specifies the fill value for sparse data explicitly. I also added a test to check for that in the future.
Before that the the matrix data was first converted to individual
pandas.SparseSeries
and passed topandas.SparseDataFrame
. This is now done directly without the intermediate allocations sinceSparseDataFrame
accepts any scipy sparse matrix. IfTable.matrix_data
can be something else than a numpy matrix or scipy sparse matrix this might not work but for now all tests seem to pass. Happy to change that back to the old behavior if that was on purpose.As a side effect
to_dataframe
is now much faster on large sparse data sets. Takes about 20s on my machine for the American Gut biom (was more than 30m before).