Skip to content

TST: Add any_string_dtype parameterization to test #44938

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 1 commit into from
Dec 17, 2021

Conversation

mroeschke
Copy link
Member

  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them

xref #44876 (comment)

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Dec 17, 2021
@mroeschke mroeschke added this to the 1.4 milestone Dec 17, 2021
# https://github.com/pandas-dev/pandas/issues/23558
# more than one char
s = Series(["a__b__c", "c__d__e", np.nan, "f__g__h", None])
s = Series(["a__b__c", "c__d__e", np.nan, "f__g__h", None], dtype=any_string_dtype)
Copy link
Member

Choose a reason for hiding this comment

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

should this affect expected.dtype?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure cc @simonjayhawkins

We don't set the expected dtype in the rest of the tests.

Copy link
Member

Choose a reason for hiding this comment

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

only if we have expand=True (the default) we get a DataFrame with the columns with the same dtype otherwise the result is an object Series of tuples of python strings.

import pandas as pd

print(pd.__version__)

s = pd.Series(["a__b__c", "c__d__e", np.nan, "f__g__h", None], dtype="string[pyarrow]")
print(s)

result1= s.str.partition(sep = "__", expand=False)
print(result1)

result2 = s.str.partition(sep="__", expand=True)
print(result2)

print(result2.dtypes)

print(repr(result2[0].dtype))
1.4.0.dev0+1658.g05b85037ab
0    a__b__c
1    c__d__e
2       <NA>
3    f__g__h
4       <NA>
dtype: string
0    (a, __, b__c)
1    (c, __, d__e)
2             <NA>
3    (f, __, g__h)
4             <NA>
dtype: object
      0     1     2
0     a    __  b__c
1     c    __  d__e
2  <NA>  <NA>  <NA>
3     f    __  g__h
4  <NA>  <NA>  <NA>
0    string
1    string
2    string
dtype: object
string[pyarrow]

Copy link
Member

Choose a reason for hiding this comment

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

OK thanks.

@simonjayhawkins simonjayhawkins merged commit 63e7ef1 into pandas-dev:master Dec 17, 2021
@simonjayhawkins
Copy link
Member

Thanks @mroeschke

@mroeschke mroeschke deleted the tst/string_dtype branch December 17, 2021 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants