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

Method _simplify_up

dask/dataframe/dask_expr/_expr.py:1375–1399  ·  view source on GitHub ↗
(self, parent, dependents)

Source from the content-addressed store, hash-verified

1373 return df.rename(columns=columns)
1374
1375 def _simplify_up(self, parent, dependents):
1376 if isinstance(parent, Projection) and isinstance(
1377 self.operand("columns"), Mapping
1378 ):
1379 reverse_mapping = {val: key for key, val in self.operand("columns").items()}
1380
1381 columns = determine_column_projection(self, parent, dependents)
1382 columns = _convert_to_list(columns)
1383 frame_columns = set(self.frame.columns)
1384 columns = [
1385 (
1386 reverse_mapping[col]
1387 if col in reverse_mapping and reverse_mapping[col] in frame_columns
1388 else col
1389 )
1390 for col in columns
1391 ]
1392 columns = [col for col in self.frame.columns if col in columns]
1393 if columns == self.frame.columns:
1394 return
1395
1396 return type(parent)(
1397 type(self)(self.frame[columns], *self.operands[1:]),
1398 *parent.operands[1:],
1399 )
1400
1401
1402class ColumnsSetter(RenameFrame):

Callers

nothing calls this directly

Calls 5

_convert_to_listFunction · 0.90
setClass · 0.85
operandMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected