Skip to content

BUG: combine_first behaves strangely with period index #3367

Closed
@kiroh

Description

@kiroh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions