I created a numpy.recarray
from a .csv-Inputfile using the csv2rec()
-Method. The Inputfile and consequently the recarray have empty rows with no data (resp. nan
-values). I want to slice this recarray at the nan
-rows into multiple sub-arrays, excluding the nan
-rows in the final arrays as shown below.
Original recarray with 2 columns:
[(1,2)
(2,2)
(nan,nan)
(nan,nan)
(4,4)
(4,3)]
2 sub-arrays without nan-values:
[(1,2)
(2,2)]
and
[(4,4)
(4,3)]
I know this could be managed using a loop but maybe there's a simpler and more elegant way? Additionally: Is it possible to keep the header-information of each column so I can refer to the columns by the parameter-name and not only the col-index after the slicing?