I have a dataframe df1 and each row of column A contains a list of numbers like so:
import pandas as pd
dic = {'A':[[0,2,5,464,64789,131,13],[1,454,45166,78],[6,8],[1],[7,8789,45,65]]}
df1 = pd.DataFrame(dic)
My goal is to save each row in a .txt file so that it displays for each row the content of the list. So far I was able to achieve it by using the following line of code:
df1.to_csv('../ndb/_fede.txt',index=False, header=None)
However the output file has some quotation marks and brackets which I don't need.
# What I get | # What I WANT!
"[0, 2, 5, 464, 64789, 131, 13]" | 0,2,5,464,64789,131,13
"[1, 454, 45166, 78]" | 1,454,45166,78
"[6, 8]" | 6,8
"[1]" | 1
"[7, 8789, 45, 65]" | 7,8789,45,65
Basically what I want is that all numbers of each list are separated by a comma and no other characters.
Note: you can also take the df1 converted into arrays if needed.