I have many dataframes that I want to combine. I only need 1 "level_0" column.
pd.concat([df_NB_E, df_LDA_E, df_DT_E, df_RF_E], axis=1)
it seems, that level_0 could be your index, right?
you have:
>>> level0 = ['ALL','AWA','REM','S1','S2','SWS']
>>> df1 = pd.DataFrame(data={'level_0':level0, 'col1':np.random.randint(0,9,6)})
>>> df2 = pd.DataFrame(data={'level_0':level0, 'col2':np.random.randint(0,9,6)})
>>> df3 = pd.DataFrame(data={'level_0':level0, 'col3':np.random.randint(0,9,6)})
>>> df1
col1 level_0
0 5 ALL
1 8 AWA
2 5 REM
3 3 S1
4 8 S2
5 4 SWS
>>> df2
col2 level_0
0 4 ALL
1 1 AWA
2 3 REM
3 2 S1
4 5 S2
5 1 SWS
>>> df3
col3 level_0
0 1 ALL
1 3 AWA
2 0 REM
3 4 S1
4 2 S2
5 3 SWS
>>> pd.concat([df1,df2,df3], axis=1)
col1 level_0 col2 level_0 col3 level_0
0 5 ALL 4 ALL 1 ALL
1 8 AWA 1 AWA 3 AWA
2 5 REM 3 REM 0 REM
3 3 S1 2 S1 4 S1
4 8 S2 5 S2 2 S2
5 4 SWS 1 SWS 3 SWS
you can set level_0 as your index, then concatenate:
>>> pd.concat([df1.set_index('level_0'), df2.set_index('level_0'), df3.set_index('level_0')], axis=1)
col1 col2 col3
level_0
ALL 5 4 1
AWA 8 1 3
REM 5 3 0
S1 3 2 4
S2 8 5 2
SWS 4 1 3
of if it's not an index, you can remove it before concat:
>>> pd.concat([df1.drop('level_0', axis=1), df2.drop('level_0', axis=1), df3.drop('level_0', axis=1)], axis=1)
col1 col2 col3
0 5 4 1
1 8 1 3
2 5 3 0
3 3 2 4
4 8 5 2
5 4 1 3
level_0columns are identical, you can delete them. Though not by name, by position (via.iloc)!