'How to I keep a list in a numpy array as a list when transforming it to a pandas dataframe?

I think I have an easy problem, but can't find a solution.

I have an array X_train with a list of strings

4    [visa, card, geldanlage, 74843e]
Name: Keyword_clean, dtype: object

Then I want to transform this to a pandas dataframe. I use the following code:

X_train = pd.DataFrame(data=X_train, columns = ['Keyword_clean'])
X_train

The X_train dataframe then looks like this

Index Keyword_clean
4 visa,card,geldanlage,74843e

What I would like to achieve is, that it looks like this (the list of the array is still kept)

Index Keyword_clean
4 [visa,card,geldanlage,74843e]

Any ideas? thanks a lot



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source