def delete(self, pos: Indices2D, axis: Optional[int] = 0, inline: bool = False) -> StructuredArray: narr = self if inline else self.copy() if isstring(pos): del narr._arrs[pos] return narr sids, aids = self._parseids(pos, axis=axis, mapslice=False) slic = isinstance(sids, slice) and sids == slice(None) alic = isinstance(aids, slice) and aids == slice(None) and (missing(axis) or axis == 0) if slic and alic: narr._arrs = OrderedDict() narr._length = None elif slic and not alic: if listable(aids) and len(aids) == 1 and aids[0] < 0: aids = aids[ 0] # fix the issue that currently negative indices are ignored by np.delete for k, v in narr._arrs.items(): narr._arrs[k] = np.delete(v, aids) narr._length = len(narr._arrs[l(narr._arrs.keys())[0]]) elif not slic and alic: if isinstance(sids, slice) or sids.dtype.kind not in ('S', 'U'): sids = narr.names[sids] for k in sids: del narr._arrs[k] else: raise IndexError('unable to delete portion of the array') return narr
def load(fname: Union[str, Path], *, mode: str = 'r', skips: Optional[int] = None, comment: Optional[str] = None, strip: bool = False, **kwargs: Any) -> List[List[str]]: checkInputFile(fname) with open(fname, mode) as f: if available(skips) and skips > 0: for _ in range(skips): next(f) tb = csv.reader(f, **kwargs) if strip: tb = drop(tb, lambda x: len(x) == 0 or (len(x) == 1 and x[0].strip() == '')) if available(comment): tb = drop(tb, lambda x: x[0].startswith(comment)) tb = l(tb) return tb
def tolist(self) -> List: return l(self._names.tolist())
def fields(self) -> List[Tuple[str, np.ndarray]]: return l(self._arrs.items())
def arrays(self) -> List[np.ndarray]: return l(self._arrs.values())
def names(self) -> np.ndarray: return np.array(l(self._arrs.keys()))