Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas concat columns

I have two df-s:

enter image description here

I want to concatenate along the columns, e.g. get a 1000x61118 DataFrame. so I'm doing:

df_full = pd.concat([df_dev, df_temp2], axis=1)
df_full

This, however, yields a 2000x61118 df, and fills everything with NaNs... And I have no idea why. What could cause this behaviour?

like image 511
lte__ Avatar asked May 17 '19 10:05

lte__


1 Answers

Create default index values by DataFrame.reset_index with drop=True for correct align both DataFrames:

df_full = pd.concat([df_dev.reset_index(drop=True), df_temp2.reset_index(drop=True)], axis=1)
like image 134
jezrael Avatar answered Sep 21 '22 15:09

jezrael