-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Improvements to str_cat #12297
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
Improvements to str_cat #12297
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 |
---|---|---|
|
@@ -251,6 +251,38 @@ the ``extractall`` method returns all matches. | |
|
||
.. _whatsnew_0180.enhancements.rounding: | ||
|
||
|
||
Changes to str.cat | ||
^^^^^^^^^^^^^^^^^^ | ||
|
||
The :ref:`.str.cat <text.cat>` concatenates the members of a Series. Before, if NaN values | ||
were present in the Series, calling `cat()` on it would return NaN, unlike the rest of the | ||
`Series.str.*` API. This behavior has been amended to ignore NaN values by default. | ||
(:issue:`11435`). | ||
|
||
A new, friendlier ValueError was also added to protect against the mistake of supplying the | ||
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. double backticks around |
||
`sep` as an arg, rather than a kwarg. | ||
(:issue:`11334`). | ||
|
||
.. code-block:: python | ||
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. make the first 2 an ipython block so they run, the 3rd can be a code-block (just so you can show the error and not the entire traceback) |
||
|
||
>>> Series(['a','b',np.nan,'c']).str.cat(sep=' ') | ||
'a b c' | ||
|
||
>>> Series(['a','b',np.nan,'c']).str.cat(sep=' ', na_rep='?') | ||
'a b ? c' | ||
|
||
>>> Series(['a','b',np.nan,'c']).str.cat(' ') | ||
--------------------------------------------------------------------------- | ||
ValueError Traceback (most recent call last) | ||
<ipython-input-3-338c379049e9> in <module>() | ||
----> 1 Series(['a','b',np.nan,'c']).str.cat(' ') | ||
|
||
[...] | ||
|
||
ValueError: Did you mean to supply a `sep` keyword? | ||
|
||
|
||
Datetimelike rounding | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
|
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.
use double backticks around
NaN
&Series
, don't use'cat()'
, use.str.cat()