pandas.Index.item — pandas 3.0.0.dev0+2102.g839747c3f6 documentation (original) (raw)
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
Returns an array representing the data in the Index.
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'