Skip to content
Advertisement

How to concatenate the column by column name in pandas?

Is there any efficient way to concatenate Pandas column name, and don’t use loop.

My current method is very slow.

input :

JavaScript

Output :

JavaScript

Advertisement

Answer

You could rework your dictionary to form groups and use groupby+agg(list):

JavaScript

output:

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