You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The source code for pandas.Index.item points to a function that doesn't have the See Also section. However, the function in the source code does have the See Also function. Yet, the See Also section is not displayed in the pandas.Index.item docstring. Furthermore, running the scripts/validate_docstrings.py --format=actions pandas.Index.item command doesn't raise a SA01 error (i.e. See Also section isn't missing).
The source link in the pandas.Index.item page points towards
@final
def item(self):
"""
Return the first element of the underlying data as a Python scalar.
Returns
-------
scalar
The first element of Series or Index.
Raises
------
ValueError
If the data is not length = 1.
Examples
--------
>>> s = pd.Series([1])
>>> s.item()
1
For an index:
>>> s = pd.Series([1], index=['a'])
>>> s.index.item()
'a'
"""
if len(self) == 1:
return next(iter(self))
raise ValueError("can only convert an array of size 1 to a Python scalar")
However, when looking at that file and function, we see the following code:
@final
def item(self):
"""
Return the first element of the underlying data as a Python scalar.
Returns
-------
scalar
The first element of Series or Index.
Raises
------
ValueError
If the data is not length = 1.
See Also
--------
Index.values : Returns an array representing the data in the Index.
Series.head : Returns the first `n` rows.
Examples
--------
>>> s = pd.Series([1])
>>> s.item()
1
For an index:
>>> s = pd.Series([1], index=["a"])
>>> s.index.item()
'a'
"""
if len(self) == 1:
return next(iter(self))
raise ValueError("can only convert an array of size 1 to a Python scalar")
Suggested fix for documentation
The text was updated successfully, but these errors were encountered:
You are viewing the stable docs (v2.2.2) and at the time of the release there wasn't a 'See Also' section in the docstring. If you view the dev docs then you will see the 'See Also' section
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/reference/api/pandas.Index.item.html
Documentation problem
The source code for
pandas.Index.item
points to a function that doesn't have theSee Also
section. However, the function in the source code does have theSee Also
function. Yet, theSee Also
section is not displayed in thepandas.Index.item
docstring. Furthermore, running thescripts/validate_docstrings.py --format=actions pandas.Index.item
command doesn't raise aSA01
error (i.e. See Also section isn't missing).The source link in the
pandas.Index.item
page points towardsHowever, when looking at that file and function, we see the following code:
Suggested fix for documentation
The text was updated successfully, but these errors were encountered: