1.) I would recommend storing column and row header information in a separate data structure. Numpy matrices can store mixed data types (in this case strings and floats), I try to avoid it. Mixing data types is messy and seems inefficient to me. If you want to, you can make your own class with your matrix data and header information in it. It seems like a cleaner solution to me.
2.) No, summaryMeansArray is set-up to have 11 rows and 6 columns. The first dimension of a matrix is the number of rows. You can get the transpose of summaryMeansArray with summaryMeansArray.T
. When you are taking the mean of summary3dArray on the 0th axis, the next axis becomes the rows and the one after that the columns.
Edit: As per request, you can create a python list from a numpy array with the method tolist()
. For instance,
newMeansArray = summaryMeansArray.tolist()
Then you can insert the column headers using
newMeansArray.insert(0,headers)
Inserting the row headers can be done with:
newMeansArray[i].insert(0,rowheader)
for each row i. Of course, if you've already inserted the column headers, then the counting for i starts with 1 rather than 0.