Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PERF/ENH] Series.map sorts a larger dataset than it needs to #14485

Open
Tracked by #14479
wence- opened this issue Nov 23, 2023 · 1 comment
Open
Tracked by #14479

[PERF/ENH] Series.map sorts a larger dataset than it needs to #14485

wence- opened this issue Nov 23, 2023 · 1 comment
Labels
no-oom Reducing memory footprint of cudf algorithms Performance Performance related issue Python Affects Python cuDF API.

Comments

@wence-
Copy link
Contributor

wence- commented Nov 23, 2023

Series.map which substitutes values in self that match some key with its corresponding value does:

            lhs = cudf.DataFrame({"x": self, "orig_order": arange(len(self))})
            rhs = cudf.DataFrame(
                {
                    "x": arg.keys(),
                    "s": arg.values(),
                    "bool": full(len(arg), True, dtype=self.dtype),
                }
            )
            res = lhs.merge(rhs, on="x", how="left").sort_values(
                by="orig_order"
            )
            result = res["s"]
            result.name = self.name
            result.index = self.index

So the order is the same as the input.

This has two pessimisations:

  1. In pandas-compat mode (since Match pandas join ordering obligations in pandas-compatible mode #14428) this merge doesn't need sorting
  2. Since we only return s, we can get away with sort_by_key of res["s"] rather than sorting a multi-column dataframe
@wence- wence- added Python Affects Python cuDF API. Performance Performance related issue no-oom Reducing memory footprint of cudf algorithms labels Nov 23, 2023
@wence-
Copy link
Contributor Author

wence- commented Nov 23, 2023

cross-ref #6724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-oom Reducing memory footprint of cudf algorithms Performance Performance related issue Python Affects Python cuDF API.
Projects
Status: Todo
Development

No branches or pull requests

1 participant