-1

How can I save a in csv? Thank you all.

print(a)

['B17' 'B8' 'B19']

['B20' 'B16' 'B17']

['B27' 'B2' 'B3']

['B2' 'B22' 'B7']

['B30' 'B12' 'B28']

['B10' 'B8' 'B15']

<class 'numpy.ndarray'>
Aswin
  • 1
  • 1

2 Answers2

1

Quick search on Stackoverflow provides an answer:

Dump a NumPy array into a csv file

Code pasted here, in case the link ever dies:

import numpy
a = numpy.asarray([ [1,2,3], [4,5,6], [7,8,9] ])
numpy.savetxt("foo.csv", a, delimiter=",")

The page also has useful alternate ways to convert it using pandas.

javapyscript
  • 720
  • 8
  • 22
0

You can use Pandas for this.

import pandas as pd


df = pd.DataFrame(a)
df.to_csv("file.csv")

Actually, nvm, numpy.savetxt is the way better.