Closed gregsifr closed 4 years ago
show df.info()
for the input frames. a copy-pastable example would be helpful.
The example provided is copy-pastable (it includes the pickled dataframes)
Below is the output from df.info():
df1.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 22 entries, 2007-04-01 to 2007-04-30
Data columns (total 2 columns):
(CUSTOMER_A, VISIT_DT) 0 non-null float64
(CUSTOMER_A, PURCHASE) 0 non-null float64
dtypes: float64(2)
memory usage: 528.0 bytes
df2.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 24 entries, 2007-04-02 to 2007-04-30
Data columns (total 2 columns):
(CUSTOMER_B, VISIT_DT) 3 non-null float64
(CUSTOMER_B, PURCHASE) 0 non-null float64
dtypes: float64(2)
memory usage: 576.0 bytes
You can't concat non-unique indexes. It doesn't make sense as these are essentially gluing blocks.
In [37]: pd.merge(df1,df2,left_index=True,right_index=True,how='outer')
Out[37]:
CUSTOMER_A CUSTOMER_B
VISIT_DT PURCHASE VISIT_DT PURCHASE
date
2007-04-01 NaN NaN NaN NaN
2007-04-02 NaN NaN NaN NaN
2007-04-03 NaN NaN NaN NaN
2007-04-04 NaN NaN NaN NaN
2007-04-05 NaN NaN NaN NaN
2007-04-06 NaN NaN NaN NaN
2007-04-09 NaN NaN NaN NaN
2007-04-10 NaN NaN NaN NaN
2007-04-11 NaN NaN NaN NaN
2007-04-12 NaN NaN NaN NaN
2007-04-13 NaN NaN NaN NaN
2007-04-16 NaN NaN NaN NaN
2007-04-17 NaN NaN NaN NaN
2007-04-18 NaN NaN NaN NaN
2007-04-19 NaN NaN NaN NaN
2007-04-20 NaN NaN NaN NaN
2007-04-23 NaN NaN NaN NaN
2007-04-24 NaN NaN NaN NaN
2007-04-25 NaN NaN NaN NaN
2007-04-26 NaN NaN NaN NaN
2007-04-27 NaN NaN NaN NaN
2007-04-29 NaN NaN 20070607.0 NaN
2007-04-29 NaN NaN 20070607.0 NaN
2007-04-29 NaN NaN 20070607.0 NaN
2007-04-30 NaN NaN NaN NaN
I think we could give a better error message here. Want to take a crack at it?
I'd be happy to take a crack at it.
gr8!
Duplicate of https://github.com/pandas-dev/pandas/issues/6963.
You get a confusing error message when trying to concat on non-unique (but also non-exactly-equal) indices. Small example:
Original reported issue by @gregsifr :