Victoria S
Victoria S

Reputation: 90

Converting List to String - Python

Really basic question, but I am trying to convert what I think is a list into a string, but it's not working.

I have a dataframe like:

<OUT> merged
ID      Tags
1     [architecture]
2     [people, loss, chocolate]
3     [rest, exif, castle]

I want to remove the '[]' and ','. I have tried but to no avail:

' '.join(str(i) for i in merged['Tags'])

Upvotes: 0

Views: 54

Answers (1)

BENY
BENY

Reputation: 323226

Let us try

merged['new'] = merged['Tags'].str.join(' ')

Upvotes: 1

Related Questions