Same
Same

Reputation: 759

Python pandas column merging

I have a dataframe similar to the following but very large:

col1 col2 0 0 0 0 1 2 3 4 5 6 0 0 In my actual table the numbers are timestamps which are in order, not in one number difference, but one is larger than the previous as shown in this dataframe. I want the two columns to be merged into a single column according the order of numbers. I want the resulting column to be like the following:

column 0 0 1 2 3 4 5 6 0

Thanks in advance.

Upvotes: 1

Views: 63

Answers (1)

Josh Rumbut
Josh Rumbut

Reputation: 2710

Ok here you go, using your contrived DF as an example:

df.column = df.col1.append(df.col2).sort_values()

Upon rereading your question you may be looking for pd.concat

df.column = pd.concat([df.col1,df.col2],axis=0)

Upvotes: 1

Related Questions