BUG: combine_first behaves strangely with period index #3367

Closed
kiroh opened this Issue Apr 15, 2013 · 11 comments

Comments

Projects
None yet
5 participants

kiroh commented Apr 15, 2013

If i do:

from pandas import Series, PeriodIndex, Period

pi = PeriodIndex(start=Period('1950-1'), freq='M', end=Period('1950-7'))
a = Series([1,nan,nan,4,5,nan,7], pi)
b = Series([9,9,9,9,9,9,9], pi)

display(a, b, a.combine_first(b))

Then the output is:

1950-01     1
1950-02   NaN
1950-03   NaN
1950-04     4
1950-05     5
1950-06   NaN
1950-07     7
Freq: M

1950-01    9
1950-02    9
1950-03    9
1950-04    9
1950-05    9
1950-06    9
1950-07    9
Freq: M

1930-01   NaN
1930-03   NaN
1930-05   NaN
1930-07   NaN
1930-09   NaN
1930-11   NaN
1931-01   NaN
Freq: M

As you can see the index is changed and the values are all gone.
I think this is a bug. My Pandas version is 0.10.1.

Contributor

y-p commented Apr 15, 2013

I can't reproduce this with git master, can you try 0.11.0rc1 and see if the problem persists?

kiroh commented Apr 15, 2013

Ok, is there any way to try 0.11.0rc1 without breaking my 0.10.1 installation?

Contributor

y-p commented Apr 15, 2013

You can use a virtualenv.

Contributor

jreback commented Apr 15, 2013

@y-p occurs in 0.11.0rc1 too, same result....

Contributor

y-p commented Apr 15, 2013

Oh my bad, I'm working with an old version. apperently it worked fine in '0.8.0.dev-092fedc'.

Contributor

jreback commented Apr 15, 2013

looking at code, its not going to work....mark for bug in 0.12 (only affects PeriodIndex), DatetimeIndex works fine

Contributor

y-p commented Apr 15, 2013

bisected? what broke it?

Contributor

jreback commented Apr 15, 2013

no idea when broken (obviously >0.8.0<0.10.1)

jreback closed this Jan 3, 2014

cganterh commented Jan 3, 2014

It's fixed?

Contributor

jreback commented Jan 3, 2014

@cganterh sorry...i think got accidently closed

jreback reopened this Jan 3, 2014

@jreback jreback modified the milestone: 0.15.0, 0.14.0 Mar 14, 2014

Member

sinhrks commented Jul 19, 2014

Current master raises TypeError: unsupported operand type(s) for +: 'PeriodIndex' and 'PeriodIndex'. #7741 will fix this.

@jreback jreback modified the milestone: 0.15.0, 0.15.1 Jul 19, 2014

jreback closed this in #7741 Jul 23, 2014

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