1new_df = df.filter(like='n_') \
2 .replace(0., np.inf) \
3 .apply(lambda x: sorted(x), axis=1, result_type='expand') \
4 .replace(np.inf, 0.0)
5
6new_df.columns = ['new_1', 'new_2', 'new_3']
7
8out = pd.concat([df, new_df], axis=1)
9