-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
DOC: Updated docstring for Series.str.cat (pandas-dev#35556) #35784
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
fea2974
da1ccc1
cc3ecec
f88843d
56db6a9
cacf136
8936c4d
2776514
c3dbf4d
542a42b
b221ef8
86de66d
952a5e7
483bfec
91ed5a4
d1556a5
ddfcd93
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 |
---|---|---|
|
@@ -2371,8 +2371,7 @@ def cat(self, others=None, sep=None, na_rep=None, join="left"): | |
join : {'left', 'right', 'outer', 'inner'}, default 'left' | ||
Determines the join-style between the calling Series/Index and any | ||
Series/Index/DataFrame in `others` (objects without an index need | ||
to match the length of the calling Series/Index). To disable | ||
alignment, use `.values` on any Series/Index/DataFrame in `others`. | ||
to match the length of the calling Series/Index). | ||
|
||
.. versionadded:: 0.23.0 | ||
.. versionchanged:: 1.0.0 | ||
|
@@ -2389,6 +2388,15 @@ def cat(self, others=None, sep=None, na_rep=None, join="left"): | |
split : Split each string in the Series/Index. | ||
join : Join lists contained as elements in the Series/Index. | ||
|
||
Notes | ||
----- | ||
Since version 1.0.0, index alignment is performed when | ||
`others` is a Series/Index/DataFrame (or a list-like containing | ||
one). To disable alignment (the behavior in and before v0.23.0), | ||
convert `others` to a numpy array while passing it as an argument | ||
(using `.to_numpy()`). See the Examples section below for more | ||
information. | ||
|
||
Examples | ||
-------- | ||
When not passing `others`, all values are concatenated into a single | ||
|
@@ -2466,7 +2474,27 @@ def cat(self, others=None, sep=None, na_rep=None, join="left"): | |
2 -c | ||
dtype: object | ||
|
||
For more examples, see :ref:`here <text.concatenate>`. | ||
When `others` is a Series/Index/DataFrame, it is advisable | ||
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. you need to explain why one should do this. e.g. to have alignment since the join is defaulting to left. show an example first with index and index, then index and series of the index and it should be more clear. |
||
to use `to_numpy()` while passing it to the function to | ||
avoid unexpected results. | ||
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. remove the 'unexpected results'. |
||
|
||
The following example demostrates this: | ||
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. this and the next paragraph both end in colons. is this paragraph needed? |
||
|
||
If `others` is a Series/Index/DataFrame and `to_numpy()` | ||
**is not** used: | ||
|
||
>>> idx = pd.Index(["a", "b", "c", "d", "e"]) | ||
>>> ser = pd.Series(["f", "g", "h", "i", "j"]) | ||
>>> idx.str.cat(ser) # the caller is an Index here | ||
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. one more space before the # |
||
Index([nan, nan, nan, nan, nan], dtype='object') | ||
|
||
When `to_numpy()` **is** used: | ||
|
||
>>> idx.str.cat(ser.to_numpy()) | ||
Index(['af', 'bg', 'ch', 'di', 'ej'], dtype='object') | ||
|
||
For other examples and usages, see | ||
:ref:`here <text.concatenate>`. | ||
""" | ||
from pandas import Index, Series, concat | ||
|
||
|
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.
is this true for an Index? If the behavior is anything like arithmetic, we would do alignment for Series/DataFrame, but Index would behave more like ndarray