tincan
tincan

Reputation: 412

Pandas concatenation results in NaNs?

What seems to be a simple function returns NaNs instead of the actual numbers. What am I missing here?

#Concatenate the dataframes:
dfcal = dfcal.astype(float)
dfmag = dfmag.astype(float)
print('dfcal\n-----',dfcal)
print('dfmag\n-----',dfmag)
df = pd.concat([dfcal,dfmag])
print('concatresult\n-----',df)

enter image description here

Cheers!

Upvotes: 1

Views: 44

Answers (2)

RKG
RKG

Reputation: 87

Check parameters (join, axis) or use merge

join{‘inner’, ‘outer’}, default ‘outer’

df = pd.concat([dfcal,dfmag], join='inner')

Upvotes: 2

jezrael
jezrael

Reputation: 862571

I guess you need axis=1 for append new columns, selected column caliper for avoid duplicated depth columns:

df = pd.concat([dfcal['caliper'],dfmag], axis=1)

Or:

df = pd.concat([dfcal.drop('depth', axis=1),dfmag], axis=1)

Upvotes: 2

Related Questions