When I do pd.concat((df1, df2), keys=('A', 'B'), ignore_index=True) it ignores the keys. I couldn't find any mention of this in the documentation, am I missing something or is this a bug?.
code example:
import pandas as pd
import numpy as np
df1 = pd.DataFrame(np.random.uniform(0, 1, (5, 5)))
df2 = pd.DataFrame(np.random.uniform(0, 1, (5, 5)))
print(pd.concat((df1, df2), keys=('A', 'B')))
print(pd.concat((df1, df2), keys=('A', 'B'), ignore_index=True))
output:
            0         1         2         3         4
A 0  0.548398  0.285250  0.690403  0.646567  0.881671
  1  0.560004  0.111783  0.155743  0.587277  0.485484
  2  0.258623  0.243698  0.881638  0.686399  0.229254
  3  0.492586  0.324359  0.922460  0.744553  0.316212
  4  0.131956  0.693708  0.620376  0.893369  0.371382
B 0  0.633036  0.402043  0.609046  0.212024  0.988794
  1  0.383615  0.575692  0.320391  0.391028  0.589542
  2  0.326453  0.879162  0.916395  0.525230  0.532779
  3  0.273823  0.229596  0.326523  0.989329  0.340129
  4  0.152274  0.445670  0.133162  0.112688  0.572573
          0         1         2         3         4
0  0.548398  0.285250  0.690403  0.646567  0.881671
1  0.560004  0.111783  0.155743  0.587277  0.485484
2  0.258623  0.243698  0.881638  0.686399  0.229254
3  0.492586  0.324359  0.922460  0.744553  0.316212
4  0.131956  0.693708  0.620376  0.893369  0.371382
5  0.633036  0.402043  0.609046  0.212024  0.988794
6  0.383615  0.575692  0.320391  0.391028  0.589542
7  0.326453  0.879162  0.916395  0.525230  0.532779
8  0.273823  0.229596  0.326523  0.989329  0.340129
9  0.152274  0.445670  0.133162  0.112688  0.572573
EDIT:
python version = 3.9.0.final.0
pandas version = 1.2.3
EDIT:
To be clear what I was expecting is:
            0         1         2         3         4
A 0  0.548398  0.285250  0.690403  0.646567  0.881671
  1  0.560004  0.111783  0.155743  0.587277  0.485484
  2  0.258623  0.243698  0.881638  0.686399  0.229254
  3  0.492586  0.324359  0.922460  0.744553  0.316212
  4  0.131956  0.693708  0.620376  0.893369  0.371382
B 5  0.633036  0.402043  0.609046  0.212024  0.988794
  6  0.383615  0.575692  0.320391  0.391028  0.589542
  7  0.326453  0.879162  0.916395  0.525230  0.532779
  8  0.273823  0.229596  0.326523  0.989329  0.340129
  9  0.152274  0.445670  0.133162  0.112688  0.572573
 
    