I have a list in each row in a dataframe and I want to merge it into one whole list.
data = {'row 1': ["text 1", "text 2", "text 3"],
'row 2': ["text 4", "text 5", "text 6"],'row 3':["text 7", "text 8", "text 9"]
}
dataframe = pd.DataFrame (data, columns = ['row 1','row 2','row 3'])
dataframe
expected output: ["text 1", "text 2", "text 3", "text 4", "text 5", "text 6", "text 7", "text 8", "text 9"]
I've tried the df.iterrows but it ended up as a list of multiple lists...
total =[]
for index, row in df.iterrows():
total.extend(row)
output: [["text 1", "text 2", "text 3"],["text 4", "text 5", "text 6"],["text 7", "text 8", "text 9"]]