-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: Updated the docstring of pandas.Series.str.get #20630
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1651,17 +1651,34 @@ def str_translate(arr, table, deletechars=None): | |
|
||
def str_get(arr, i): | ||
""" | ||
Extract element for each component. | ||
|
||
Extract element from lists, tuples, or strings in each element in the | ||
Series/Index. | ||
|
||
Parameters | ||
---------- | ||
i : int | ||
Integer index (location) | ||
Integer index (location). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this not very clear. May be something like "Position of the element to extract"? |
||
|
||
Returns | ||
------- | ||
items : Series/Index of objects | ||
|
||
Examples | ||
-------- | ||
>>> x = pd.Series(["String", (1, 2, 4), ["a", "b", "c"]]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The standard way is to name the Series |
||
>>> x | ||
0 String | ||
1 (1, 2, 4) | ||
2 [a, b, c] | ||
dtype: object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a numerical value, to show what happens. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
|
||
>>> x.str.get(1) | ||
0 t | ||
1 2 | ||
2 b | ||
dtype: object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be a example with a negative value too? |
||
""" | ||
f = lambda x: x[i] if len(x) > i >= -len(x) else np.nan | ||
return _na_map(f, arr) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not very clear. May be "Extract element from the specified position" or "Extract element from the specified position in a list or string" if not too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. How about, "Extract element for each component from the specified position." or "Extract the element from the specified position for all elements in Series."; something along those lines?