how to collapse columns in pandas on null values?
问题 Suppose I have the following dataframe: pd.DataFrame({'col1': ["a", "a", np.nan, np.nan, np.nan], 'override1': ["b", np.nan, "b", np.nan, np.nan], 'override2': ["c", np.nan, np.nan, "c", np.nan]}) col1 override1 override2 0 a b c 1 a NaN NaN 2 NaN b NaN 3 NaN NaN c 4 NaN NaN NaN Is there a way to collapse the 3 columns into one column, where override2 overrides override1 , which overrides col1 , however, in case there is NaN, then the values bofore is to be kept? Also, I am mainly looking for