| 608 | |
| 609 | |
| 610 | class DropDuplicates(Unique): |
| 611 | _parameters = [ |
| 612 | "frame", |
| 613 | "subset", |
| 614 | "ignore_index", |
| 615 | "split_every", |
| 616 | "split_out", |
| 617 | "shuffle_method", |
| 618 | "keep", |
| 619 | ] |
| 620 | _defaults = { |
| 621 | "subset": None, |
| 622 | "ignore_index": False, |
| 623 | "split_every": None, |
| 624 | "split_out": True, |
| 625 | "shuffle_method": "tasks", |
| 626 | "keep": "first", |
| 627 | } |
| 628 | chunk = M.drop_duplicates |
| 629 | aggregate_func = M.drop_duplicates |
| 630 | |
| 631 | @property |
| 632 | def split_by(self): |
| 633 | return self.subset |
| 634 | |
| 635 | @functools.cached_property |
| 636 | def _meta(self): |
| 637 | return make_meta( |
| 638 | self.chunk(meta_nonempty(self.frame._meta), **self.chunk_kwargs) |
| 639 | ) |
| 640 | |
| 641 | @property |
| 642 | def chunk_kwargs(self): |
| 643 | out = {"keep": self.keep} |
| 644 | if is_dataframe_like(self.frame._meta): |
| 645 | out["subset"] = self.subset |
| 646 | if not is_index_like(self.frame._meta): |
| 647 | out["ignore_index"] = self.ignore_index |
| 648 | return out |
| 649 | |
| 650 | def _simplify_up(self, parent, dependents): |
| 651 | if self.subset is not None and isinstance(parent, Projection): |
| 652 | columns = determine_column_projection( |
| 653 | self, parent, dependents, additional_columns=self.subset |
| 654 | ) |
| 655 | if set(columns) == set(self.frame.columns): |
| 656 | # Don't add unnecessary Projections, protects against loops |
| 657 | return |
| 658 | |
| 659 | columns = [col for col in self.frame.columns if col in columns] |
| 660 | return type(parent)( |
| 661 | type(self)(self.frame[columns], *self.operands[1:]), |
| 662 | *parent.operands[1:], |
| 663 | ) |
| 664 | |
| 665 | |
| 666 | class PivotTable(ApplyConcatApply): |
no outgoing calls
no test coverage detected