Hi, I am relatively new to numpy and am seeking some advice on an appropriate way to do the following simple task.
The idea is to build a class that will allow a user to easily remove and keep columns and rows in a 2D numpy array. An outline of the class is as follows: class DataEditor(object): def __init__(self, data_array): self.data_array = data_array self.edited_data_array = None def get_edited_data(self): return self.edited_data_array def remove_cols(self, a_list_of_column_numbers): """remove the specified columns, but keep the rest""" # some functionality to produce self.edited_data_array def remove_rows(self, a_list_of_row_numbers): """remove the specified rows, but keep the rest""" # some functionality to produce self.edited_data_array def keep_cols(self, a_list_of_column_numbers): """keep the specified columns, but remove the rest""" # some functionality to produce self.edited_data_array def keep_rows(self, a_list_of_row_numbers): """keep the specified rows, but remove the rest""" # some functionality to produce self.edited_data_array Usage would be something like the following: >> import numpy as np >> import data_editor >> data = np.random.rand(7,9) >> editor = data_editor.DataEditor(data) >> editor.remove_rows([2,4]) >> editor.keep_cols([3,5,7]) >> edited_data = data_editor.get_edited_array() I don't have much experience using them, but would using a masked array would make sense in this context? If so, how does one convert a masked array to a 'normal' array with only the unmasked values present from the original? Or, is another approach more appropriate. Thank you for your help. -Brad _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion