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-#6696: Use cached dtypes in fillna when possible. #6697

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

AndreyPavlenko
Copy link
Collaborator

What do these changes do?

  • first commit message and PR title follow format outlined here

    NOTE: If you edit the PR title to match this format, you need to add another commit (even if it's empty) or amend your last commit for the CI job that checks the PR title to pick up the new PR title.

  • passes flake8 modin/ asv_bench/benchmarks scripts/doc_checker.py
  • passes black --check modin/ asv_bench/benchmarks scripts/doc_checker.py
  • signed commit with git commit -s
  • Resolves PERF: Use cached dtypes in fillna when possible. #6696
  • tests added and passing
  • module layout described at docs/development/architecture.rst is up-to-date

Copy link
Collaborator

@dchigarev dchigarev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, besides the changes related to laziness, let's separate them and discuss in a separate PR

modin/core/storage_formats/pandas/query_compiler.py Outdated Show resolved Hide resolved
Comment on lines +2505 to +2509
dtype = pandas.Series(value).dtype
if all(
find_common_type([t, dtype]) == t for t in self._modin_frame.dtypes
):
new_dtypes = self._modin_frame.dtypes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't we simply fill new dtypes with the find_common_type results?

Suggested change
dtype = pandas.Series(value).dtype
if all(
find_common_type([t, dtype]) == t for t in self._modin_frame.dtypes
):
new_dtypes = self._modin_frame.dtypes
dtype = pandas.Series(value).dtype
new_dtypes = pandas.Series({col: find_common_type([t, dtype]) for col, t in self._modin_frame.dtypes.items()})

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the new dtype depends on whether there are NAs in the frame or not. If there no NAs, the dtype is not changed, otherwise, it's changed to the common. We can't analyze the data here, but we can make the assumption, that the dtype will not changed if it's already the common one.

value_dtypes = pandas.DataFrame(
{k: [v] for (k, v) in value.items()}
).dtypes
if all(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dchigarev dchigarev self-requested a review November 13, 2023 14:58
@dchigarev dchigarev merged commit 41ecc92 into modin-project:master Nov 13, 2023
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PERF: Use cached dtypes in fillna when possible.
3 participants