Reputation: 3
I have a dataframe with firstname, middlename, lastname. How do I merge these columns so that I have one column with fullname including NULL for middlenname in between if it is not there in data ex: john?
df
first_name middle_name last_name
0 bob K smith
1 john smith
2 bill R smith
output
full_name
0 bobKsmith
1 john smith
2 billRsmith
Upvotes: 0
Views: 28
Reputation: 815
This works as expected:
df.replace('', " ", inplace = True)
df["concat"] = df.sum(axis = 1)
Upvotes: 1