I want to save a numpy array into a CSV file. My code gives me an error:
import os
import pandas as pd
import numpy as np
path ='/Users/mas/Documents/workspace/Avito/input/' # path to testing file
sample = pd.read_csv(path + 'sampleSubmission.csv')
index = sample.ID.values - 1
test = np.array(pd.read_csv(path + 'dataset5test.csv'))
#print new[0:10,:]
new = test[index,:]
np.savetxt(path + 'testSearchStream9.csv', new, delimiter=",")
os.system('say "Done"')
This is the error that I get:
np.savetxt(path + 'testSearchStream9.csv', new, delimiter=",")
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/npyio.py", line 1061, in savetxt
fh.write(asbytes(format % tuple(row) + newline))
TypeError: float argument required, not str