Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
n = 5
p = 2
dfA = pd.DataFrame(np.random.rand(n,p),
columns=['A0','B0'],
index=pd.period_range(start='2000-1-1',periods=n,freq='Y'))
dfQ = pd.DataFrame(np.random.rand(n,p),
columns=['A0','B0'],
index=pd.period_range(start='2000-1-1',periods=n,freq='Q'))
dfM = pd.DataFrame(np.random.rand(n,p),
columns=['A0','B0'],
index=pd.period_range(start='2000-1-1',periods=n,freq='M'))
df1 = dfA.loc[:,['A0']].T.stack()
df2 = dfA.loc[:,['B0']].T.stack()
df3 = dfQ.loc[:,['A0']].T.stack()
df4 = dfQ.loc[:,['B0']].T.stack()
df5 = dfM.loc[:,['A0']].T.stack()
df6 = dfM.loc[:,['B0']].T.stack()
# these work
pd.concat([df1,df4])
pd.concat([df1,df2])
pd.concat([df1,df3])
pd.concat([df1,df2,df3])
pd.concat([dfA['A0'],dfQ['A0'],dfM['A0']])
# error
pd.concat([df1,df3,df2])
pd.concat([df1,df2,df3,df4])
pd.concat([df1,df3,df5])
Issue Description
pd.concat() can concatenate 3 multi-index dataframes when they have 2 frequencies, but cannot concatenate 4 dataframes.
Expected Behavior
pd.concat() should be able to concatenate a list of mixed-freq multiindex dataframes no matter how many items the list has.
Installed Versions
Comment From: rhshadrach
Thanks for the report, agreed this looks inconsistent. I'm guessing we should raise rather than converting to object dtype. @jbrockmendel - any thoughts?
Comment From: dberardi99
take
Comment From: kubaszkliniarz
@dberardi99 - hey, would you mind if I take it over?
Comment From: dberardi99
@dberardi99 - hey, would you mind if I take it over?
Ofc, feel free to work on it