I am trying to create a file with several lines as header and append a column of numbers. I am having some issue appending a numpy.matrix after a header. I wrote a code as below
import numpy as np
import pandas as pd
import xlrd
df = pd.read_csv('Region_SGeMS.csv', header=None)
matrix = np.asmatrix(df)
#print(matrix)
s = np.shape(matrix)
print(s)
row = s[0]
col = s[1]
a = np.flip(matrix, 0)
b = np.reshape(a, (400, 1))
print(b)
f = open('Region.txt', 'w')
f.write(str(s[0]))
f.write(' ')
f.write(str(s[1]))
f.write(' 1 \n')
f.write('1 \n')
f.write('facies \n')
with open('Region.txt', 'a+') as outfile:
np.savetxt(outfile,b)
However, the highlighted number should be 2, not 0. I also attached a screenshot of my original excel file. Here is a screenshot of my result

b[:10]- i.e the first part ofb?numpy.matrixobjects, stick to normal multi-dimensional arrays.