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

Function _clean_by_expr

dask/dataframe/dask_expr/_groupby.py:1328–1349  ·  view source on GitHub ↗
(obj, by)

Source from the content-addressed store, hash-verified

1326
1327
1328def _clean_by_expr(obj, by):
1329 if (
1330 isinstance(by, Series)
1331 and by.name in obj.columns
1332 and obj.ndim == 2
1333 and by._name == obj[by.name]._name
1334 ):
1335 return by.name
1336 elif isinstance(by, Index) and by._name == obj.index._name:
1337 return by.expr
1338 elif isinstance(by, (Series, Index)):
1339 if not are_co_aligned(obj.expr, by.expr):
1340 raise NotImplementedError(
1341 "by must be in the DataFrames columns or aligned with the DataFrame."
1342 )
1343 if isinstance(by, Index):
1344 by = by.to_series()
1345 by.index = obj.index
1346 return by.expr
1347
1348 # By is a column name, e.g. str or int
1349 return by
1350
1351
1352class GroupByCumulative(Expr, GroupByBase):

Callers 1

__init__Method · 0.85

Calls 2

are_co_alignedFunction · 0.90
to_seriesMethod · 0.45

Tested by

no test coverage detected