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

Index.map followups #18482

Open
jreback opened this Issue Nov 25, 2017 · 11 comments

Comments

Projects
None yet
4 participants
@jreback
Contributor

jreback commented Nov 25, 2017

xref #15081, a couple of issues

  • IntervalIndex.map is xfailed
  • parametrize indexex/common.py/test_map similar to how indexex/datetimelike.py/test_map is done (IOW on dict / Series) (#18491)
  • resolve datetimelike with empty map [2] should be all NaT for the datetimelikes. (#18491)
In [2]: pd.date_range('20130101', periods=3).map({})
Out[2]: Float64Index([nan, nan, nan], dtype='float64')

In [3]: pd.Index([1,2,3]).map({})
Out[3]: Float64Index([nan, nan, nan], dtype='float64')
@jreback

This comment has been minimized.

Contributor

jreback commented Nov 25, 2017

cc @jorisvandenbossche (point 3)
cc @jschendel (point 1)

jreback added a commit to jreback/pandas that referenced this issue Nov 25, 2017

@jschendel

This comment has been minimized.

Member

jschendel commented Nov 26, 2017

Regarding point 1: To be clear, the underlying issue referenced here is #16410, right? test_map xpasses locally for me, and that was the closest thing I could find based on the xfail message. The problem described in #16410 is still occurring, but I haven't immediately been able to produce any errors with map using a similar setup.

@jschendel

This comment has been minimized.

Member

jschendel commented Nov 26, 2017

Side note: should mapping an empty dictionary against an IntervalIndex return an IntervalIndex? Currently returns a Float64Index, which seems kind of strange:

In [2]: pd.interval_range(0, 4).map({})
Out[2]: Float64Index([nan, nan, nan, nan], dtype='float64')
@jreback

This comment has been minimized.

Contributor

jreback commented Nov 26, 2017

@jschendel I just noticed that test_interval.py/test_map is xfailed. It might have been disabled during this re-factoring. if that is the case, then just need to re-eable.

#18491 fixes all of the Indexes to return correctly there own type if {} is passed. I think II should do the same (but again still xfailed).

jreback added a commit to jreback/pandas that referenced this issue Nov 26, 2017

@jorisvandenbossche

This comment has been minimized.

Member

jorisvandenbossche commented Nov 27, 2017

@jreback Is there a specific reason you pinged me for point 3 ? (apart from general attention)

@jreback

This comment has been minimized.

Contributor

jreback commented Nov 27, 2017

@jorisvandenbossche no, you had raised the point in the original issue (note this is all now resolved by #18491)

@jorisvandenbossche

This comment has been minimized.

Member

jorisvandenbossche commented Nov 27, 2017

Ah, I forgot that one :-)

@jreback jreback modified the milestones: 0.23.0, Next Major Release Apr 14, 2018

@louispotok

This comment has been minimized.

Contributor

louispotok commented May 2, 2018

(I don't know if this is the right place to put this, happy to open a new issue if that's better.)

According to my reading of this PR, the following should work as of 0.22.0:

s = pd.Series({0:'a',1:'b'})
s.index.map(pd.Series({0:'c',1:'d'})) 

But for me it throws a ValueError. Whereas this works fine:

s = pd.Series({0:'a',1:'b'})
pd.Series(s.index).map(pd.Series({0:'c',1:'d'}))```
@jschendel

This comment has been minimized.

Member

jschendel commented May 2, 2018

@louispotok : The PR you linked to has a milestone of 0.23.0, so the behavior should only work as of that release (should be relatively soon):

In [2]: pd.__version__
Out[2]: '0.23.0rc2'

In [3]: s = pd.Series({0:'a',1:'b'})

In [4]: s.index.map(pd.Series({0:'c',1:'d'}))
Out[4]: Index(['c', 'd'], dtype='object')
@louispotok

This comment has been minimized.

Contributor

louispotok commented May 2, 2018

Oh thanks @jschendel , my mistake: I saw this event putting it in the 0.22.0, and didn't see that the milestone was later moved.

@jschendel

This comment has been minimized.

Member

jschendel commented May 2, 2018

Ah, I was basing the 0.23.0 milestone off the right hand side summary at the top of the PR. Probably moved to 0.23.0 after the fact; the 0.22.0 release happened pretty shortly after 0.21.x and only contained one major change. Many things originally slated for 0.22.0 got moved to 0.23.0 after the being merged to accommodate the new plan for the 0.22.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment