Q:

Write a NumPy program to save as text a matrix which has in each row 2 float and 1 string at the end

0

Write a NumPy program to save as text a matrix which has in each row 2 float and 1 string at the end.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
matrix = [[1, 0, 'aaa'], [0, 1, 'bbb'], [0, 1, 'ccc']]
np.savetxt('test', matrix, delimiter='  ', header='string', comments='', fmt='%s')

Sample Output:
string
1  0  aaa
0  1  bbb
0  1  ccc

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now