- Notifications
You must be signed in to change notification settings - Fork 19.4k
SparseArray is an ExtensionArray #22325
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
Changes from 1 commit
ee187eb 32c1372 b265659 8dfc898 9c57725 13952ab 7a6e7fa 1016af1 072abec 0ad61cc 5b0b524 224744a 620b5fb 164c401 65f83d6 0b3c682 69a5d13 f2b5862 fa80fc5 3f20890 484adb0 1df1190 4246ac4 a849699 c4da319 a2f158f 26b671a 375e160 0a37050 3c2cb0f 27c6378 e52dae9 b6d8430 640c4a5 6b61597 427234f e055629 a79359c de3aa71 21f4ee3 c1e594a dc7f93f eb09d21 7dcf4b2 b39658a a8b76bd e041313 595535e 7700299 f1ff7da 33fa6f7 40c035e 1d49cc7 6f4b6b6 6f037b5 7da220e bfbe4ab c5666b6 ff6037c 5c362ef 55cac36 c4e8784 a00f987 a6d7eac 4b4f9bd 82801be 1a149dc fde19d7 a7ba8f6 5064217 e31e8aa 79c8e9c 26993fe 6eeec11 50de326 5ef1747 f31970c f1b860f 5c44275 33bc8f8 9bf13ad de1fb5b da580cd 88b73c3 afde64d e603d3d ec5eb9a a72ee1a f147635 c35c7c2 e159ef2 d48a8fa 3bcf57e 31d401f a4369c2 608b499 14e60c9 550f163 821cc91 e21ed21 aeb8c8c 34c90ed 2103959 26af959 e5920c2 084a967 bb17760 dde7852 f1b4e6b 6a31077 02aa7f7 3a7ee2d d6fe191 b1ea874 2213b83 94664c4 e54160c 04a2dbb fb01d1a f78ae81 11d5b40 ba70753 82bab3c 2990124 a9d0f17 0c52c37 998f113 38b0356 7206d94 fe771b5 12e424c 3bd567f f816346 1a1dcf4 e3d9173 2715cdb 4e40599 0aa3934 a3becb6 5660b9a dd3cba5 cc65b8a 06dce5f f7351d3 2055494 f310322 0008164 027f6d8 c0d9875 44b218c 47fa73a c2c489f 3729927 9ba49e1 543ac7c f66ef6f ba8fc9d 9185e33 11799ab 73e7626 ebece16 7db6990 be21f42 e857363 d0ee038 54f4417 2082d86 f846606 ce8e0ac 1f6590e b758469 f6b0924 232518c e8b37da 0197e0c 62326ae f008c38 88c6126 5c8662e 78798cf b051424 78979b6 2333db1 b41d473 d6a2479 a23c27c 7372eb3 cab8c54 52ae275 9c9b49e f5d7492 b4b4cbc bf98b9d f3d2681 7d4d3ba 57c03c2 0dbc33e c217cf5 2ea7a91 8f2f228 c83bed7 53e494e 627b9ce df0293a a590418 7821f19 ee26c52 40390f1 15a164d 88432c8 3e7ec90 7b0a179 20d8815 3e81c69 1098a7a 10d204a 69075d8 0764baa a4a47c5 a5b6c39 70d8268 7aed79f 11e55aa 11606af 2f73179 1b3058a f4ec928 8c67ca2 cc89ec7 3f713d4 886fe03 75099af 731fc06 f91141d 37a4b57 4aad8e1 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| # coding=utf-8 | ||
| # pylint: disable-msg=E1101,W0612 | ||
| import pytest | ||
| | ||
| import numpy as np | ||
| import pandas as pd | ||
| from pandas.core.sparse.dtype import SparseDtype | ||
| import pandas.util.testing as tm | ||
| | ||
| | ||
| | @@ -47,29 +49,29 @@ def test_subclass_sparse_slice(self): | |
| s = tm.SubclassedSparseSeries([1, 2, 3, 4, 5]) | ||
| exp = tm.SubclassedSparseSeries([2, 3, 4], index=[1, 2, 3]) | ||
| tm.assert_sp_series_equal(s.loc[1:3], exp) | ||
| assert s.loc[1:3].dtype == np.int64 | ||
| assert s.loc[1:3].dtype == SparseDtype(np.int64) | ||
| | ||
| exp = tm.SubclassedSparseSeries([2, 3], index=[1, 2]) | ||
| tm.assert_sp_series_equal(s.iloc[1:3], exp) | ||
| assert s.iloc[1:3].dtype == np.int64 | ||
| assert s.iloc[1:3].dtype == SparseDtype(np.int64) | ||
| | ||
| exp = tm.SubclassedSparseSeries([2, 3], index=[1, 2]) | ||
| tm.assert_sp_series_equal(s[1:3], exp) | ||
| assert s[1:3].dtype == np.int64 | ||
| assert s[1:3].dtype == SparseDtype(np.int64) | ||
| | ||
| # float64 | ||
| s = tm.SubclassedSparseSeries([1., 2., 3., 4., 5.]) | ||
| exp = tm.SubclassedSparseSeries([2., 3., 4.], index=[1, 2, 3]) | ||
| tm.assert_sp_series_equal(s.loc[1:3], exp) | ||
| assert s.loc[1:3].dtype == np.float64 | ||
| assert s.loc[1:3].dtype == SparseDtype(np.float64) | ||
| | ||
| exp = tm.SubclassedSparseSeries([2., 3.], index=[1, 2]) | ||
| tm.assert_sp_series_equal(s.iloc[1:3], exp) | ||
| assert s.iloc[1:3].dtype == np.float64 | ||
| assert s.iloc[1:3].dtype == SparseDtype(np.float64) | ||
| | ||
| exp = tm.SubclassedSparseSeries([2., 3.], index=[1, 2]) | ||
| tm.assert_sp_series_equal(s[1:3], exp) | ||
| assert s[1:3].dtype == np.float64 | ||
| assert s[1:3].dtype == SparseDtype(np.float64) | ||
| | ||
| def test_subclass_sparse_addition(self): | ||
| s1 = tm.SubclassedSparseSeries([1, 3, 5]) | ||
| | @@ -82,6 +84,7 @@ def test_subclass_sparse_addition(self): | |
| exp = tm.SubclassedSparseSeries([5., 7., 9.]) | ||
| tm.assert_sp_series_equal(s1 + s2, exp) | ||
| | ||
| @pytest.mark.xfail(reason="XXX: SS used to reindex. Now we match Series.") | ||
| ||
| def test_subclass_sparse_to_frame(self): | ||
TomAugspurger marked this conversation as resolved. Show resolved Hide resolved | ||
| s = tm.SubclassedSparseSeries([1, 2], index=list('abcd'), name='xxx') | ||
| res = s.to_frame() | ||
| | ||
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.
Do we know of specific consequences that people might run into because of this?
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.
mmm not sure.
isinstance(sparse_array, np.ndarray)? :)The main thing is that there are many method implemented in ndarray that are not on SparseArray. Hard to say what's most used.