pandas.Series.str.cat¶
- Series.str.cat(others=None, sep=None, na_rep=None)¶
- Concatenate strings in the Series/Index with given separator. - Parameters: - others : list-like, or list of list-likes - If None, returns str concatenating strings of the Series - sep : string or None, default None - na_rep : string or None, default None - If None, an NA in any array will propagate - Returns: - concat : Series/Index of objects or str - Examples - If others is specified, corresponding values are concatenated with the separator. Result will be a Series of strings. - >>> Series(['a', 'b', 'c']).str.cat(['A', 'B', 'C'], sep=',') 0 a,A 1 b,B 2 c,C dtype: object - Otherwise, strings in the Series are concatenated. Result will be a string. - >>> Series(['a', 'b', 'c']).str.cat(sep=',') 'a,b,c' - Also, you can pass a list of list-likes. - >>> Series(['a', 'b']).str.cat([['x', 'y'], ['1', '2']], sep=',') 0 a,x,1 1 b,y,2 dtype: object