Skip to content
Advertisement

Join columns in a single Pandas DataFrame

I’ve DataFrame with 4 columns and want to merge the first 3 columns in a new DataFrame.

The data is identical, the order is irrelevant and any duplicates must remain.

JavaScript

Desired DataFrame

JavaScript

How do I get this done?

Advertisement

Answer

Here is one way of merging the first three columns with the help of numpy:

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement