So,I want to concatenate three columns in pandas by taking first 3 letters from Column1 and first 4 letters from column2 and all 4 digits from column3 and store them in column4 but whenever there is Nan in even one of column 1,2 or 3,I want the output as Nan or Blank like below.Even if there are less letters then concatenate but even if there is one Nan then don't.
Column1 Column2 Column3 Column4
Abcdef cdefg 1996 ABC|CDEF|1996
ab wer 1998 AB|WER|1998
ab NaN 1998 NaN/Blank
NaN NaN 2000 NaN/Blank
abcd weet NaN NaN/Blank
qwwer ram2e 12345 QWW|RAM2|1234
I tried the following code but its very basic and not giving desired output.Please suggest a better alternative.Thanks.
df1['column4'] = df1['column1'].str[:3]+df1['column2'].str[:4]+df1['column3'].map(str)