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

Method _simplify_up

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

Source from the content-addressed store, hash-verified

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