Skip to content

Commit e1fb30b

Browse files
vipinkjonwaljorisvandenbossche
authored andcommitted
DOC: update the str_cat() docstring (Delhi) (#20171)
1 parent 0ba1fae commit e1fb30b

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

pandas/core/strings.py

+24-14
Original file line numberDiff line numberDiff line change
@@ -51,46 +51,56 @@ def str_cat(arr, others=None, sep=None, na_rep=None):
5151
"""
5252
Concatenate strings in the Series/Index with given separator.
5353
54+
If `others` is specified, this function concatenates the Series/Index
55+
and elements of `others` element-wise.
56+
If `others` is not being passed then all values in the Series are
57+
concatenated in a single string with a given `sep`.
58+
5459
Parameters
5560
----------
56-
others : list-like, or list of list-likes
57-
If None, returns str concatenating strings of the Series
61+
others : list-like, or list of list-likes, optional
62+
List-likes (or a list of them) of the same length as calling object.
63+
If None, returns str concatenating strings of the Series.
5864
sep : string or None, default None
65+
If None, concatenates without any separator.
5966
na_rep : string or None, default None
6067
If None, NA in the series are ignored.
6168
6269
Returns
6370
-------
6471
concat : Series/Index of objects or str
6572
73+
See Also
74+
--------
75+
split : Split each string in the Series/Index
76+
6677
Examples
6778
--------
68-
When ``na_rep`` is `None` (default behavior), NaN value(s)
69-
in the Series are ignored.
79+
When not passing `other`, all values are concatenated into a single
80+
string:
7081
71-
>>> Series(['a','b',np.nan,'c']).str.cat(sep=' ')
82+
>>> s = pd.Series(['a', 'b', np.nan, 'c'])
83+
>>> s.str.cat(sep=' ')
7284
'a b c'
7385
74-
>>> Series(['a','b',np.nan,'c']).str.cat(sep=' ', na_rep='?')
86+
By default, NA values in the Series are ignored. Using `na_rep`, they
87+
can be given a representation:
88+
89+
>>> pd.Series(['a', 'b', np.nan, 'c']).str.cat(sep=' ', na_rep='?')
7590
'a b ? c'
7691
77-
If ``others`` is specified, corresponding values are
92+
If `others` is specified, corresponding values are
7893
concatenated with the separator. Result will be a Series of strings.
7994
80-
>>> Series(['a', 'b', 'c']).str.cat(['A', 'B', 'C'], sep=',')
95+
>>> pd.Series(['a', 'b', 'c']).str.cat(['A', 'B', 'C'], sep=',')
8196
0 a,A
8297
1 b,B
8398
2 c,C
8499
dtype: object
85100
86-
Otherwise, strings in the Series are concatenated. Result will be a string.
87-
88-
>>> Series(['a', 'b', 'c']).str.cat(sep=',')
89-
'a,b,c'
90-
91101
Also, you can pass a list of list-likes.
92102
93-
>>> Series(['a', 'b']).str.cat([['x', 'y'], ['1', '2']], sep=',')
103+
>>> pd.Series(['a', 'b']).str.cat([['x', 'y'], ['1', '2']], sep=',')
94104
0 a,x,1
95105
1 b,y,2
96106
dtype: object

0 commit comments

Comments
 (0)