Skip to content
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

BUG: Series.get() with ExtensionArray and integer index #21260

Merged
merged 6 commits into from
Jun 29, 2018

Conversation

Dr-Irv
Copy link
Contributor

@Dr-Irv Dr-Irv commented May 30, 2018

@codecov
Copy link

codecov bot commented May 30, 2018

Codecov Report

Merging #21260 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #21260      +/-   ##
==========================================
+ Coverage    91.9%   91.92%   +0.02%     
==========================================
  Files         154      153       -1     
  Lines       49557    49572      +15     
==========================================
+ Hits        45544    45568      +24     
+ Misses       4013     4004       -9
Flag Coverage Δ
#multiple 90.32% <100%> (+0.04%) ⬆️
#single 41.8% <0%> (-0.22%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.63% <100%> (ø) ⬆️
pandas/io/common.py 70.28% <0%> (-0.93%) ⬇️
pandas/core/dtypes/cast.py 88.22% <0%> (-0.27%) ⬇️
pandas/util/_test_decorators.py 92.5% <0%> (-0.19%) ⬇️
pandas/core/indexing.py 93.55% <0%> (-0.18%) ⬇️
pandas/compat/__init__.py 58.43% <0%> (-0.18%) ⬇️
pandas/core/generic.py 96.12% <0%> (-0.09%) ⬇️
pandas/io/pytables.py 92.43% <0%> (-0.05%) ⬇️
pandas/core/series.py 94.17% <0%> (-0.02%) ⬇️
pandas/core/algorithms.py 94.83% <0%> (-0.02%) ⬇️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0801b8c...0854a06. Read the comment docs.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

I think we should really consider making get more strict in general (not the integer fallback), xref #17928 but that is again not for this PR

This was not actually tested for Series of datetimetz or categorical type? (as those should also take this path?)
It might be good to add some general tests for Series.get that covers this.

@jorisvandenbossche jorisvandenbossche added Bug ExtensionArray Extending pandas with custom dtypes or arrays. labels May 30, 2018
@Dr-Irv
Copy link
Contributor Author

Dr-Irv commented May 31, 2018

@jorisvandenbossche I added tests for .get a variety of Series types in this last commit, which includes datetimetz ones. category was already handled by pandas/tests/extension/category/test_categorical.py which picks up the base test in pandas/tests/extension/base/getitem.py

@@ -81,6 +81,7 @@ Indexing
- Bug in :meth:`Series.reset_index` where appropriate error was not raised with an invalid level name (:issue:`20925`)
- Bug in :func:`interval_range` when ``start``/``periods`` or ``end``/``periods`` are specified with float ``start`` or ``end`` (:issue:`21161`)
- Bug in :meth:`MultiIndex.set_names` where error raised for a ``MultiIndex`` with ``nlevels == 1`` (:issue:`21149`)
- Bug in :meth:`Series.get` for ``Series`` using ``ExtensionArray`` and integer index (:issue:`21257`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to 0.24.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

def test_get(self):
for o in self.objs:
if isinstance(o, Series):
s = o.set_axis([2 * i for i in range(len(o))], inplace=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just directly construct a Series with the provided values rather than trying to convolute this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -998,6 +998,42 @@ def test_validate_bool_args(self):
with pytest.raises(ValueError):
self.int_series.drop_duplicates(inplace=value)

def test_get(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in pandas/tests/series/test_indexing (and pandas/tests/frame/test_indexing)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it to pandas/tests/series/indexing/test_indexing and parameterized the test

Note for dataframes, df.get() has a meaning to get the column, not the row, so I didn't put a test there.

@jreback jreback added this to the 0.24.0 milestone Jun 29, 2018
@jreback
Copy link
Contributor

jreback commented Jun 29, 2018

@Dr-Irv this looks good. just rebased. ping on green here.

@jreback jreback merged commit 5c761f1 into pandas-dev:master Jun 29, 2018
@jreback
Copy link
Contributor

jreback commented Jun 29, 2018

thanks!

@Dr-Irv Dr-Irv deleted the issue21257 branch June 29, 2018 13:44
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series.get() on ExtensionArray with integer key not in index returns incorrect result
3 participants