Skip to content

Commit ec58e4e

Browse files
IsvenCjreback
authored andcommitted
DOC: Update the Series.str.len docstring (#22187)
1 parent 720d263 commit ec58e4e

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

pandas/core/strings.py

+39-2
Original file line numberDiff line numberDiff line change
@@ -2814,11 +2814,48 @@ def rindex(self, sub, start=0, end=None):
28142814
return self._wrap_result(result)
28152815

28162816
_shared_docs['len'] = ("""
2817-
Compute length of each string in the Series/Index.
2817+
Computes the length of each element in the Series/Index. The element may be
2818+
a sequence (such as a string, tuple or list) or a collection
2819+
(such as a dictionary).
28182820
28192821
Returns
28202822
-------
2821-
lengths : Series/Index of integer values
2823+
Series or Index of int
2824+
A Series or Index of integer values indicating the length of each
2825+
element in the Series or Index.
2826+
2827+
See Also
2828+
--------
2829+
str.len : Python built-in function returning the length of an object.
2830+
Series.size : Returns the length of the Series.
2831+
2832+
Examples
2833+
--------
2834+
Returns the length (number of characters) in a string. Returns the
2835+
number of entries for dictionaries, lists or tuples.
2836+
2837+
>>> s = pd.Series(['dog',
2838+
... '',
2839+
... 5,
2840+
... {'foo' : 'bar'},
2841+
... [2, 3, 5, 7],
2842+
... ('one', 'two', 'three')])
2843+
>>> s
2844+
0 dog
2845+
1
2846+
2 5
2847+
3 {'foo': 'bar'}
2848+
4 [2, 3, 5, 7]
2849+
5 (one, two, three)
2850+
dtype: object
2851+
>>> s.str.len()
2852+
0 3.0
2853+
1 0.0
2854+
2 NaN
2855+
3 1.0
2856+
4 4.0
2857+
5 3.0
2858+
dtype: float64
28222859
""")
28232860
len = _noarg_wrapper(len, docstring=_shared_docs['len'], dtype=int)
28242861

0 commit comments

Comments
 (0)