Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG: Slicing subclasses of SparseDataFrames. #13787
Conversation
sstanovnik
changed the title from
[FIX] Slicing subclasses of SparseDataFrames. to BUG: Slicing subclasses of SparseDataFrames.
Jul 25, 2016
jreback
and 1 other
commented on an outdated diff
Jul 25, 2016
| @@ -373,7 +373,9 @@ def _slice(self, slobj, axis=0, kind=None): | ||
| new_index = self.index | ||
| new_columns = self.columns[slobj] | ||
| - return self.reindex(index=new_index, columns=new_columns) | ||
| + return self._constructor(data=self.reindex(index=new_index, |
jreback
Contributor
|
jreback
and 1 other
commented on an outdated diff
Jul 25, 2016
| @@ -210,3 +210,17 @@ def test_subclass_align_combinations(self): | ||
| tm.assert_series_equal(res1, exp2) | ||
| tm.assertIsInstance(res2, tm.SubclassedDataFrame) | ||
| tm.assert_frame_equal(res2, exp1) | ||
| + | ||
| + def test_subclass_sparse_slice(self): | ||
| + ssdf = tm.SubclassedSparseDataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) |
jreback
Contributor
|
jreback
and 2 others
commented on an outdated diff
Jul 25, 2016
| @@ -210,3 +210,17 @@ def test_subclass_align_combinations(self): | ||
| tm.assert_series_equal(res1, exp2) | ||
| tm.assertIsInstance(res2, tm.SubclassedDataFrame) | ||
| tm.assert_frame_equal(res2, exp1) | ||
| + | ||
| + def test_subclass_sparse_slice(self): | ||
| + ssdf = tm.SubclassedSparseDataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) | ||
| + ssdf.testattr = "testattr" | ||
| + | ||
| + tm.assertIsInstance(ssdf.loc[:2], tm.SubclassedSparseDataFrame) |
jreback
Contributor
|
|
is there a specific issue for this? @sinhrks pls have a look |
jreback
added Sparse Compat
labels
Jul 25, 2016
codecov-io
commented
Jul 25, 2016
•
Current coverage is 85.25% (diff: 100%)@@ master #13787 diff @@
==========================================
Files 140 140
Lines 50455 50471 +16
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43014 43031 +17
+ Misses 7441 7440 -1
Partials 0 0
|
|
Thank you for your comments, I made changes according to them:
|
sinhrks
commented on an outdated diff
Jul 26, 2016
sinhrks
commented on an outdated diff
Jul 26, 2016
|
@sstanovnik thx for update! i linked the PR from #10627, so new issue is not needed unless there is something which is not fixid in this PR. |
|
Should I also squash the commits? |
|
not mandatory on your side. will be done during merge. |
|
Typo fixed, rebased. |
|
Two old pickling tests failed: see this build. I didn't see a nice way out, so I made an exception for the deprecated SparseTimeSeries. This may not be what you want and needs review. |
|
@sstanovnik yeah |
jreback
commented on the diff
Jul 27, 2016
| @@ -210,3 +210,25 @@ def test_subclass_align_combinations(self): | ||
| tm.assert_series_equal(res1, exp2) | ||
| tm.assertIsInstance(res2, tm.SubclassedDataFrame) | ||
| tm.assert_frame_equal(res2, exp1) | ||
| + | ||
| + def test_subclass_sparse_slice(self): |
jreback
Contributor
|
|
I added additional tests to check other subclassing changes I made. |
|
lgtm; though I think the read_pickle assertion can be done in a clearer way (use sep function). @sinhrks ? |
sinhrks
commented on an outdated diff
Jul 29, 2016
| @@ -44,8 +44,15 @@ def compare_element(self, result, expected, typ, version=None): | ||
| return | ||
| if typ.startswith('sp_'): | ||
| + # SparseTimeSeries deprecated in 0.17.0 | ||
| + if (typ == "sp_series" and version and |
sinhrks
Member
|
sinhrks
commented on an outdated diff
Jul 29, 2016
| @@ -86,6 +86,13 @@ def compare(self, vf, version): | ||
| comparator(result, expected, typ, version) | ||
| return data | ||
| + def compare_sp_series_ts(self, res, exp, typ, version): | ||
| + # SparseTimeSeries deprecated in 0.17.0 | ||
| + if version and LooseVersion(version) < "0.17.0": |
sinhrks
Member
|
|
@sstanovnik looks good. @sinhrks anything further? |
jreback
added this to the
0.19.0
milestone
Jul 29, 2016
|
None. thanks for all the effort, @sstanovnik ! |
|
@sstanovnik lgtm. pls add a whatsnew note (put in API changes). ping when green. |
sstanovnik
added some commits
Jul 25, 2016
|
ping |
jreback
closed this
in a7f7e1d
Aug 2, 2016
|
thanks @sstanovnik |
sstanovnik commentedJul 25, 2016
•
edited
git diff upstream/master | flake8 --diffThis changes
SparseDataFrameto use proper subclassing functionality so slicing of subclasses ofSparseDataFrameworks. Example of a failure that this PR fixes: