MCPcopy Create free account
hub / github.com/modAL-python/modAL / drop_rows

Function drop_rows

modAL/utils/data.py:125–148  ·  view source on GitHub ↗

Returns X without the row(s) at index/indices I

(
    X: modALinput, I: Union[int, List[int], np.ndarray]
)

Source from the content-addressed store, hash-verified

123
124
125def drop_rows(
126 X: modALinput, I: Union[int, List[int], np.ndarray]
127) -> Union[sp.csc_matrix, np.ndarray, pd.DataFrame]:
128 """
129 Returns X without the row(s) at index/indices I
130 """
131 if sp.issparse(X):
132 mask = np.ones(X.shape[0], dtype=bool)
133 mask[I] = False
134 return retrieve_rows(X, mask)
135 elif isinstance(X, pd.DataFrame):
136 return X.drop(I, axis=0)
137 elif isinstance(X, np.ndarray):
138 return np.delete(X, I, axis=0)
139 elif isinstance(X, list):
140 return np.delete(X, I, axis=0).tolist()
141
142 try:
143 if torch.is_tensor(blocks[0]):
144 return torch.cat(blocks)
145 except:
146 X[[True if row not in I else False for row in range(X.size(0))]]
147
148 raise TypeError("%s datatype is not supported" % type(X))
149
150
151def enumerate_data(X: modALinput):

Callers 1

expected_error_reductionFunction · 0.90

Calls 1

retrieve_rowsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…