'How to Delist a dataframe row whose value is a list [duplicate]

I want to convert the below data frame into space-separated in python. Like:

0  ['raj', 'kumar']
1  ['kill', 'bill']

To

0  raj kumar
1  kill bill


Solution 1:[1]

try using reduce for each row in the dataframe

data=[{'value': ['raj', 'kumar']},
{'value':  ['kill', 'bill']}]
df=pd.DataFrame(data)
print(df)
def concatWords(lst):
    return functools.reduce(lambda x,y: x+" "+y,lst)
df["value"]=df["value"].apply(concatWords)
print(df)

output:

value
0  raj kumar
1  kill bill

Sources

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

Source: Stack Overflow

Solution Source
Solution 1