Skip to content

support tuple in startswith/endswith for arrow strings #56580

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 6 commits into from
Dec 21, 2023

Conversation

rohanjain101
Copy link
Contributor

@rohanjain101 rohanjain101 commented Dec 20, 2023

result = getattr(ser.str, side)(pat, na=na)
expected = pd.Series(exp, dtype=ArrowDtype(pa.bool_()))
tm.assert_series_equal(result, expected)


@pytest.mark.parametrize("side", ("startswith", "endswith"))
def test_str_starts_ends_with_all_nulls_empty_tuple(side):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this test because in case of empty tuple, code to create series is:

result = pc.if_else(pc.is_null(self._pa_array), None, False)

I thought that if self._pa_array was all nulls, that resulting datatype may be null[pyarrow] (when we want bool[pyarrow]), I added this test to validate that bool is preserved, even in all nulls case.

rohanjain101 and others added 2 commits December 21, 2023 01:08
Co-authored-by: Xiao Yuan <yuanx749@gmail.com>
Co-authored-by: Xiao Yuan <yuanx749@gmail.com>
@phofl phofl added this to the 2.2 milestone Dec 21, 2023
@phofl phofl added Strings String extension data type and string data Arrow pyarrow functionality labels Dec 21, 2023
@phofl phofl merged commit 9379642 into pandas-dev:main Dec 21, 2023
@phofl
Copy link
Member

phofl commented Dec 21, 2023

thx @rohanjain101

@rohanjain101 rohanjain101 deleted the startswith_tuple branch December 21, 2023 21:13
cbpygit pushed a commit to cbpygit/pandas that referenced this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series.str.startswith/endswith don't support tuple pattern for pd.ArrowDtype(pa.string())
3 participants