I want to save the numpy array as a csv file in python
For example given the following array
a = [[1,2,3], [4,5,6], [7,8,9]]
I would like to have a csv file like :
1 4 7
2 5 8
3 6 9
My code bellow gives me the result like :
a.tofile('file1.csv',sep=',')
result: 1 2 3 4 5 6 7 8 9
I have tried the following code as well
df = pd.DataFrame(a)
df.to_csv("file2.csv", index=None)
which does not give me the desired result again
1
2
3
4
5
6
7
8
9
I would appreciate your comments and suggestion.
