-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: Subclassed DataFrame slicing may return normal Series
closes #11559 Author: sinhrks <sinhrks@gmail.com> Closes #12906 from sinhrks/subclass_slice and squashes the following commits: fa112f6 [sinhrks] BUG: Subclassed DataFrame slicing may return normal Series
- Loading branch information
Showing
4 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# coding=utf-8 | ||
# pylint: disable-msg=E1101,W0612 | ||
|
||
import pandas.util.testing as tm | ||
|
||
|
||
class TestSeriesSubclassing(tm.TestCase): | ||
|
||
_multiprocess_can_split_ = True | ||
|
||
def test_indexing_sliced(self): | ||
s = tm.SubclassedSeries([1, 2, 3, 4], index=list('abcd')) | ||
res = s.loc[['a', 'b']] | ||
exp = tm.SubclassedSeries([1, 2], index=list('ab')) | ||
tm.assert_series_equal(res, exp) | ||
tm.assertIsInstance(res, tm.SubclassedSeries) | ||
|
||
res = s.iloc[[2, 3]] | ||
exp = tm.SubclassedSeries([3, 4], index=list('cd')) | ||
tm.assert_series_equal(res, exp) | ||
tm.assertIsInstance(res, tm.SubclassedSeries) | ||
|
||
res = s.ix[['a', 'b']] | ||
exp = tm.SubclassedSeries([1, 2], index=list('ab')) | ||
tm.assert_series_equal(res, exp) | ||
tm.assertIsInstance(res, tm.SubclassedSeries) | ||
|
||
def test_to_frame(self): | ||
s = tm.SubclassedSeries([1, 2, 3, 4], index=list('abcd'), name='xxx') | ||
res = s.to_frame() | ||
exp = tm.SubclassedDataFrame({'xxx': [1, 2, 3, 4]}, index=list('abcd')) | ||
tm.assert_frame_equal(res, exp) | ||
tm.assertIsInstance(res, tm.SubclassedDataFrame) |
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