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: fix wrong error message in deprecated 2D indexing of Series with datetime values #38099

Merged

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Nov 26, 2020

Closes #35527

For most Series types, this was properly raising the deprecation warning about 2D being deprecated, but for Series with datetimetz values, this started raising an AssertionError instead of only raising the warning.

@jorisvandenbossche jorisvandenbossche added Regression Functionality that used to work in a prior pandas version Deprecate Functionality to remove in pandas labels Nov 26, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.1.5 milestone Nov 26, 2020
data (values.ndim == 2), which should only be allowed if ndim is
also 2.
"""
if ndim is None:
Copy link
Member

Choose a reason for hiding this comment

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

we recently started always-passing ndim to the constructor, so should never have None here

Copy link
Contributor

Choose a reason for hiding this comment

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

this is backported though, so prob ok (but will need a patch on 1.2)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is also done in the parent method, so can use a general clean-up for 1.2

Copy link
Contributor

Choose a reason for hiding this comment

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

kk can you open an issue so we don't forget to do this

@jbrockmendel
Copy link
Member

LGTM pending green. I'm OK with this solution, or with working the check into the existing check_ndim.

data (values.ndim == 2), which should only be allowed if ndim is
also 2.
"""
if ndim is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

this is backported though, so prob ok (but will need a patch on 1.2)

with tm.assert_produces_warning(FutureWarning):
s[:, None]
res = series[:, None]
Copy link
Contributor

Choose a reason for hiding this comment

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

prob worth testing the actual message (can pass to assert_produces_warning to prevent regressions.

s[:, None]
res = series[:, None]

assert isinstance(res, np.ndarray)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you assert the result arrays (parameterize if needed)

@jreback
Copy link
Contributor

jreback commented Nov 29, 2020

@jorisvandenbossche if you can update

):
result = series[:, None]

assert isinstance(result, np.ndarray)
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessary but nbd

result = series[:, None]

assert isinstance(result, np.ndarray)
tm.assert_numpy_array_equal(result, np.asarray(series)[:, None])
Copy link
Contributor

Choose a reason for hiding this comment

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

really pref the
result=
expected=
assert_*

as its what we always want to model

@simonjayhawkins simonjayhawkins mentioned this pull request Nov 30, 2020
@jreback
Copy link
Contributor

jreback commented Nov 30, 2020

@jorisvandenbossche if you can update for the small comments above

@jreback jreback merged commit 03771a2 into pandas-dev:master Dec 1, 2020
@jreback
Copy link
Contributor

jreback commented Dec 1, 2020

thanks @jorisvandenbossche

@jorisvandenbossche jorisvandenbossche deleted the regr-2d-indexing-error branch December 1, 2020 07:11
@simonjayhawkins
Copy link
Member

@meeseeksdev backport 1.1.x

@lumberbot-app

This comment has been minimized.

@jorisvandenbossche
Copy link
Member Author

@simonjayhawkins will do the backport

jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this pull request Dec 1, 2020
@simonjayhawkins
Copy link
Member

Thanks @jorisvandenbossche

simonjayhawkins pushed a commit that referenced this pull request Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AssertionError in multidimensional indexing of a Series
4 participants