Given the following:
df = pd.DataFrame({\'col1\' : [\"a\",\"b\"],
\'col2\' : [\"ab\",np.nan], \'col3\' : [\"w\",\"e\"]})
I would l
You can use dropna()
df['col4'] = df.apply(lambda row: '*'.join(row.dropna()), axis=1)
UPDATE:
Since, you need to convert numbers and special chars too, you can use astype(unicode)
In [37]: df = pd.DataFrame({'col1': ["a", "b"], 'col2': ["ab", np.nan], "col3": [3, u'\xf3']})
In [38]: df.apply(lambda row: '*'.join(row.dropna().astype(unicode)), axis=1)
Out[38]:
0 a*ab*3
1 b*ó
dtype: object
In [39]: df['col4'] = df.apply(lambda row: '*'.join(row.dropna().astype(unicode)), axis=1)
In [40]: df
Out[40]:
col1 col2 col3 col4
0 a ab 3 a*ab*3
1 b NaN ó b*ó