merging multiple columns into one columns in pandas
问题 I have a dataframe called ref(first dataframe) with columns c1, c2 ,c3 and c4. ref= pd.DataFrame([[1,3,.3,7],[0,4,.5,4.5],[2,5,.6,3]], columns=['c1','c2','c3','c4']) print(ref) c1 c2 c3 c4 0 1 3 0.3 7.0 1 0 4 0.5 4.5 2 2 5 0.6 3.0 I wanted to create a new column i.e, c5 ( second dataframe) that has all the values from columns c1,c2,c3 and c4. I tried concat, merge columns but i cannot get it work. Please let me know if you have a solutions? 回答1: You can use unstack for creating Series from