Skip to content

ENH: Add StringMethod.find and rfind #9386

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
Feb 16, 2015
Merged

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Feb 1, 2015

Derived from #9111.

end : int
Right edge index
side : {'left', 'right'}, default 'left'

Copy link
Member

Choose a reason for hiding this comment

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

I would document this as switching between find (left side) and rfind (right side).

@sinhrks sinhrks force-pushed the string_find branch 2 times, most recently from 96e0799 to a3298db Compare February 2, 2015 13:13
@sinhrks
Copy link
Member Author

sinhrks commented Feb 2, 2015

Thanks, fixed.

@shoyer
Copy link
Member

shoyer commented Feb 2, 2015

OK, looks good to me.

def str_find(arr, sub, start=0, end=None, side='left'):
"""
Return indexes in each strings where the substring is
wholly contained between [start:end]. Return -1 on failure.
Copy link
Member

Choose a reason for hiding this comment

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

'wholly' sounds a bit odd to me (non-native speaker), is 'fully' better?

@jorisvandenbossche
Copy link
Member

@sinhrks I added some documentation comments. Further:

  • I think you may group all the StringMethods enhancement in a section under 'new features' (as it starts to become a large list)
  • Maybe we should start adding versionadded directives (see here) to newly added functions? We don't do this consistently right now, but I think we should do that more.

@jorisvandenbossche jorisvandenbossche added the Strings String extension data type and string data label Feb 2, 2015
@jorisvandenbossche jorisvandenbossche added this to the 0.16.0 milestone Feb 2, 2015
@jorisvandenbossche
Copy link
Member

and another:

  • maybe add a 'Notes' section saying it is equivalent to the standard library's str.find (I even think you can link to that using :func:str.find``

@sinhrks
Copy link
Member Author

sinhrks commented Feb 3, 2015

Modified once.

  • About release note, let me do once finish StringMethods should have the same methods as standard str #9111 (added as AI).
  • Adding Notes is duplicated with the "Method Summary" in text.rst. How about adding Notes in each docstring, and change "Method Summary" section to a simple link to "String handling" section in api.rst.

""")

@Appender(_shared_docs['find'] % dict(side='lowest',
also='rfind : Return highest indexes in each strings'))
Copy link
Member

Choose a reason for hiding this comment

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

I think rfind has to be Series.str.rfind (and same below)

@jorisvandenbossche
Copy link
Member

And on the note, I don't think that is a problem that is would be duplicated (that is the point of having both docstrings and narrative docs, there will always be some duplication).

If the table in text.rst can be replaced by an autosummary table is separate issue I think. Positive side is that it would add the explanation manually, but at the moment I like more how the table looks in text.rst (better overview) than how it is on the api pages.

@jorisvandenbossche
Copy link
Member

It is maybe not necessary to add it in a Note, just adding 'equivalent to standard library's str.find' in the explanation in the beginning of the docstring is also good.

@sinhrks sinhrks force-pushed the string_find branch 2 times, most recently from 47f6ce7 to f4089b7 Compare February 5, 2015 14:32
@sinhrks
Copy link
Member Author

sinhrks commented Feb 5, 2015

Maybe my word choice is inappropriate. What I'm caring is uniformity of styles and descriptions. What I expect is all the docstring should have similar format, and sufficient information in a single place.

In this respect, current doc should be revised in separate PR to cover:

  • All the docstring should provide "better overview" and this should be used both in "text.rst" and "api.rst".
  • Add descriptions for standard string methods (not only find and rfind).

This is one thing, and added a description for this PR.

jreback added a commit that referenced this pull request Feb 16, 2015
ENH: Add StringMethod.find and rfind
@jreback jreback merged commit cbbcffe into pandas-dev:master Feb 16, 2015
@jreback
Copy link
Contributor

jreback commented Feb 16, 2015

thanks @sinhrks

@sinhrks sinhrks deleted the string_find branch March 31, 2015 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants