Reputation: 137
I got a dataframe looking like this:
A B C
0 1 2 3
1 2 2 1
I want to send the values from the dataframe into a HTTP POST where the format looks like this:
"1,2,3",
"2,2,1",
How is it possible to format the output from the dataframe to be able to achieve desired output?
Upvotes: 1
Views: 146
Reputation: 862511
You can convert values to strings if need join them:
L = df.astype(str).agg(','.join, 1).tolist()
print (L)
['1,2,3', '2,2,1']
For json
output convert list:
import json
j = json.dumps(L)
print (j)
["1,2,3", "2,2,1"]
Upvotes: 1