(self, parent, dependents)
| 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 | |
| 1399 | class ColumnsSetter(RenameFrame): |
nothing calls this directly
no test coverage detected