Skip to content

Conversation

hamdanal
Copy link
Contributor

@hamdanal hamdanal commented Aug 3, 2025

Added simple default values to the str accessor.

I made a few more changes for things I noticed while adding default values:

  • Added a dtype parameter to str.decode
  • Fixed the type of str.get key, its documented to accept hashable objects not just int
  • Made the table of str.translate covariant as it does not modify the input object
  • Marked str.wrap parameters as keyword-only (at runtime they are passed through **kwargs) and fixed their type
  • Simplified some redundant overloads and added missing tests for some edge cases

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

All looks good, except for a past thing that I should have caught in a past PR review.

Comment on lines 363 to 367
check(
assert_type(s.str.partition(expand=False), "pd.Series[type[object]]"),
pd.Series,
object,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It appears that I missed something when _T_OBJECT was created. We don't want to have Series[object] or Series[type[object]] in the stubs. So can you change the definition of T_OBJECT to be just Series (since we won't know the type) and then change the tests referring to Series[type[object]] to just be Series ?

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

thanks @hamdanal

@Dr-Irv Dr-Irv merged commit 51d30a9 into pandas-dev:main Aug 4, 2025
13 checks passed
@hamdanal hamdanal deleted the str-defaults branch August 4, 2025 18:52
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.

3 participants