Skip to content

PERF: BooleanArray._from_sequence_of_strings #50613

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

Merged
merged 3 commits into from
Jan 7, 2023

Conversation

lukemanley
Copy link
Member

@lukemanley lukemanley commented Jan 7, 2023

Also removes the need to xfail when parsing a pyarrow array of strings.

import pandas as pd
import numpy as np
from pandas.core.arrays.boolean import BooleanArray

choices = BooleanArray._TRUE_VALUES.union(BooleanArray._FALSE_VALUES)
choices = np.array(list(choices), dtype=object)
strings = np.random.choice(choices, 10**5, replace=True)

%timeit BooleanArray._from_sequence_of_strings(strings)

# 43.4 ms ± 1.04 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)  -> main
# 21.9 ms ± 120 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)   -> PR

@lukemanley lukemanley added the Performance Memory or execution speed performance label Jan 7, 2023
@phofl phofl added this to the 2.0 milestone Jan 7, 2023
Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

lgtm

@phofl phofl merged commit 76c39d5 into pandas-dev:main Jan 7, 2023
@phofl
Copy link
Member

phofl commented Jan 7, 2023

thx @lukemanley

@lukemanley lukemanley deleted the boolean-array-from-strings branch January 19, 2023 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants