I want to create a CSV file like this:
Features, Value
f1, 1
f2, 2
f3, 3
But I get this:
f1, f2, f3
1, 2, 3
The code I wrote:
my_dict = {'f1': 1, 'f2': 2, 'f3': 3}
with open('testcsv.csv', 'w') as f:
w = csv.DictWriter(f, my_dict.keys())
w.writeheader()
w.writerow(my_dict)
What should I do?