MCPcopy Create free account
hub / github.com/dask/dask / __getitem__

Method __getitem__

dask/dataframe/dask_expr/_collection.py:439–464  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

437 return new_collection, (self._expr,)
438
439 def __getitem__(self, other):
440 if isinstance(other, FrameBase):
441 if not expr.are_co_aligned(self.expr, other.expr):
442 return new_collection(expr.FilterAlign(self, other))
443 return new_collection(self.expr.__getitem__(other.expr))
444 elif isinstance(other, slice):
445 from pandas.api.types import is_float_dtype
446
447 is_integer_slice = any(
448 isinstance(i, Integral) for i in (other.start, other.step, other.stop)
449 )
450 if (
451 self.ndim == 2
452 and is_integer_slice
453 and (not is_float_dtype(self.index.dtype) or PANDAS_GE_300)
454 ):
455 return self.iloc[other]
456 else:
457 return self.loc[other]
458 if isinstance(other, np.ndarray) or is_series_like(other):
459 other = list(other)
460 elif isinstance(other, list):
461 other = other.copy()
462 elif isinstance(other, np.generic):
463 other = other.item()
464 return new_collection(self.expr.__getitem__(other))
465
466 def __dask_tokenize__(self):
467 return type(self).__name__, self._expr._name

Callers

nothing calls this directly

Calls 5

new_collectionFunction · 0.90
anyFunction · 0.85
is_series_likeFunction · 0.85
__getitem__Method · 0.45
copyMethod · 0.45

Tested by

no test coverage detected