Hello all,
I need to take a csv file and import this data into a multi-dimensional array in python, but I am not sure how to strip the 'None' values out of the array after I have appended my data to the empty array.
I first created a structure like this:
storecoeffs = numpy.empty((5,11), dtype='object')
This returns an 5 row by 11 column array populated by 'None'.
Next, I opened my csv file and converted it to an array:
coeffsarray = list(csv.reader(open("file.csv")))
coeffsarray = numpy.array(coeffsarray, dtype='object')
Then, I appended the two arrays:
newmatrix = numpy.append(storecoeffs, coeffsarray, axis=1)
The result is an array populated by 'None' values followed by the data that I want (first two rows shown to give you an idea as to the nature of my data):
array([[None, None, None, None, None, None, None, None, None, None, None,
workers, constant, hhsize, inc1, inc2, inc3, inc4, age1, age2,
age3, age4],[None, None, None, None, None, None, None, None, None, None, None,
w0, 7.334, -1.406, 2.823, 2.025, 0.5145, 0, -4.936, -5.054, -2.8, 0],,...]], dtype=object)
How do I remove those 'None' objects from each row so what I am left with is the 5 x11 multidimensional array with my data?
Thanks in advance!