-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update str.cat example #23723
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
DOC: update str.cat example #23723
Changes from 1 commit
7982f69
2655e8b
75ef297
f744052
2180da6
ccf14a3
a381c95
fc1d2dd
5d59dd1
b75c415
3f8d4fd
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 |
---|---|---|
|
@@ -306,21 +306,24 @@ The same alignment can be used when ``others`` is a ``DataFrame``: | |
Concatenating a Series and many objects into a Series | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
All one-dimensional list-likes can be combined in a list-like container (including iterators, ``dict``-views, etc.): | ||
Several items can be combined a list-like container (including iterators, ``dict``-views, etc.), which may contain ``Series``, ``Index`` and ``np.ndarray``. | ||
Note that ``Index`` will align as well, so we change the indexes of ``s`` and ``u`` to strings for the purpose of this example: | ||
|
||
.. ipython:: python | ||
|
||
s | ||
u | ||
s.str.cat([u.values, | ||
u.index.astype(str).values], na_rep='-') | ||
s2 = s.set_axis(['a', 'b', 'c', 'd'], inplace=False) | ||
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 is not obvious at all, just directly construct the Series will be much more clear |
||
s2 | ||
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. add this in multiple blocks as its too much to complicated 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. this whole example needs to be simpler. maybe just leave the index as integers to avoid confusion, IOW focus less on the join in str.cat and more on the list-lke things that are going on. 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. |
||
u2 = u.set_axis(['b', 'd', 'a', 'c'], inplace=False) | ||
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. same here |
||
u2 | ||
s2.str.cat([pd.Index(['d', 'c', 'b', 'a']), u2, u2.values], na_rep='-', join='left') | ||
|
||
All elements must match in length to the calling ``Series`` (or ``Index``), except those having an index if ``join`` is not None: | ||
All ``np.ndarrays`` within the passed list-like must match in length to the calling ``Series`` (or ``Index``), | ||
but ``Series`` and ``Index`` may have arbitrary length (as long as alignment is not disabled with ``join is not None``): | ||
|
||
.. ipython:: python | ||
|
||
v | ||
s.str.cat([u, v], join='outer', na_rep='-') | ||
s.str.cat([v, u, u.values], join='outer', na_rep='-') | ||
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. Instead of accessing |
||
|
||
If using ``join='right'`` on a list of ``others`` that contains different indexes, | ||
the union of these indexes will be used as the basis for the final concatenation: | ||
|
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.
not sure what this last statement about Index actually means. can you reword.