-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: iloc misbehavior with pd.Series: sometimes returns pd.Categorical, fixes #14580 #14642
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
Conversation
@@ -409,6 +409,23 @@ def test_getitem_callable(self): | |||
result = s[lambda x: [True, False, True, True]] | |||
tm.assert_series_equal(result, s.iloc[[0, 2, 3]]) | |||
|
|||
def test_getitem_category_type(self): |
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.
put this in the test_categorical.py instead
@@ -1595,6 +1595,15 @@ def _get_slice_axis(self, slice_obj, axis=0): | |||
else: | |||
return self.obj.take(slice_obj, axis=axis, convert=False) | |||
|
|||
def _get_list_axis(self, key_list, axis=0): | |||
|
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 add a comment on what this is doing
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.
Could you give a hint on phrasing please?
Would "return Series values by list or array of integers" be clear enough?
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.
so ideally add a Paramaters/Returns section (I know we don't have docs for other of the internal functions, but have to start :))
yes but be clear that this is a posiitional indexer
Current coverage is 84.53% (diff: 90.00%)@@ master #14642 diff @@
==========================================
Files 144 144
Lines 51058 51061 +3
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 43177 43166 -11
- Misses 7881 7895 +14
Partials 0 0
|
8e0d697
to
56e0117
Compare
It looks like appveyor CI check failed due to connectivity problem. Is it possible to restart it? |
cddb441
to
c7454ea
Compare
@nathalier Can you add a whatsnew note for this? |
|
||
# get slice | ||
result = s.iloc[0:1] | ||
self.assertEqual(type(result), type(s)) |
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 use tm.assert_series_equal
for these (IOW, construct the expected series)
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.
@jreback Thank you! Corrected.
Before, iloc on pd.Series returned Categorical object for list-like indexes input, while Series object is expected. Fixes pandas-dev#14580
_get_list_axis() is factored out of _getitem_axis() to handle list-like type of input.
Add test to verify type of returned value of iloc() Series of Categorical data.
c7454ea
to
f6b1790
Compare
@jorisvandenbossche I added whatsnew to 0.19.2. Is it OK? |
thanks! |
git diff upstream/master | flake8 --diff
closes #14580