arrays - Convert numpy arry to csv file in python -


i want save numpy array csv file in python

for example given following array

a = [[1,2,3], [4,5,6], [7,8,9]] 

i have csv file :

 1   4    7  2   5    8  3   6    9 

my code bellow gives me result :

a.tofile('file1.csv',sep=',')  result:  1 2 3 4 5 6 7 8 9  

i have tried following code well

df = pd.dataframe(a)  df.to_csv("file2.csv", index=none) 

which not give me desired result again

1     2     3     4     5 6 7 8 9 

i appreciate comments , suggestion.

you pd.dataframe(a).t.to_csv('file2.csv', index=false, header=none)

in [1210]: print pd.dataframe(a).t.to_csv(index=false, header=none) 1,4,7 2,5,8 3,6,9 

enter image description here


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -