Skip to content
Advertisement

Python concat through a list of strings inside a dataframe

I have this df:

JavaScript

I need to transform each value in attach list to a link: For example:

JavaScript

Where each value is the key in link to download.

I tried to use apply func but doesn’t worked:

JavaScript

the following error is displayed:
TypeError: can only concatenate str (not “list”) to str

Advertisement

Answer

Take a look at the error message: It tells you that you are trying to concatenate a list to a str, which only can be referring to the ‘+’ operations you use in the lambda function. You almost had it right, though, as you just need to consider the fact that the entries in ‘attach’ are lists of strings and not strings themselves:

JavaScript

should work.

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