Skip to content

pd.concat on two (or more) series produces all-NaN dataframe #11058

Closed
@timfeirg

Description

@timfeirg

this is from a stackoverflow question here, you can download serialized object here and reproduce using python 2.7 and pandas 0.16.2.

I'm trying to concat two series with multiindex using pd.concat([a, b], axis=1) like so:

>>>payed_orders.head()
dt          product_id
2015-01-15  10001          1
            10007          1
            10016         14
            10022          1
            10023          1
Name: payed_orders, dtype: int64

>>>refund_orders.head()
dt          product_id
2015-01-15  10007         1
            10016         4
            10030         1
2015-01-16  10007         3
            10008         1
Name: refund_orders, dtype: int64

>>>pd.concat([payed_orders.head(), refund_orders.head()], axis=1, ignore_index=False)
        payed_orders    refund_orders
dt  product_id      
2015-01-15  10001   NaN NaN
            10007   NaN NaN
            10016   NaN NaN
            10022   NaN NaN
            10023   NaN NaN
            10030   NaN NaN
2015-01-16  10007   NaN NaN
            10008   NaN NaN

I've checked the index type and many other stuff to make sure no obvious were made, I've read the docs to learn that concatenating and merging series and dataframes may introduce NaN, but I didn't find anything in the docs to explain this behavior.

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