I currently have a pandas dataframe. The concatenation of the 1st and 2nd columns results in the 3rd column.
I've tried the df.fillna(") method to cope with the NaN values. However I need to get rid of the NaN's in the concatenated column. While the above method only gets rid of the existing columns.
import pandas as pd
import numpy as np
data = [[], ['arthur','shelby',''], ['michael','','']]
df = pd.DataFrame(data, columns = ['Name', 'LastName','FullName'])
df['FullName'] = df['Name'].map(str) + ' ' + (df['LastName'].map(str))
df1 = df.fillna("")
print(df1)
The output results column contains NaN NaN for the 1st row. However I'm expecting it to be " " " " enter image description here.
Anyway to achieve this???