Skip to content

Commit ac3d893

Browse files
akoselTomAugspurger
authored andcommitted
DOC: update the DataFrame.at[] docstring (#20290)
* DOC: update the DataFrame.at[] docstring * Fix line length * Update based on comments * Update indexing.py
1 parent 0596cb1 commit ac3d893

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

pandas/core/indexing.py

+42-3
Original file line numberDiff line numberDiff line change
@@ -1888,11 +1888,50 @@ def __setitem__(self, key, value):
18881888

18891889

18901890
class _AtIndexer(_ScalarAccessIndexer):
1891-
"""Fast label-based scalar accessor
1891+
"""
1892+
Access a single value for a row/column label pair.
1893+
1894+
Similar to ``loc``, in that both provide label-based lookups. Use
1895+
``at`` if you only need to get or set a single value in a DataFrame
1896+
or Series.
1897+
1898+
See Also
1899+
--------
1900+
DataFrame.iat : Access a single value for a row/column pair by integer
1901+
position
1902+
DataFrame.loc : Access a group of rows and columns by label(s)
1903+
Series.at : Access a single value using a label
1904+
1905+
Examples
1906+
--------
1907+
>>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
1908+
... index=[4, 5, 6], columns=['A', 'B', 'C'])
1909+
>>> df
1910+
A B C
1911+
4 0 2 3
1912+
5 0 4 1
1913+
6 10 20 30
1914+
1915+
Get value at specified row/column pair
1916+
1917+
>>> df.at[4, 'B']
1918+
2
1919+
1920+
Set value at specified row/column pair
1921+
1922+
>>> df.at[4, 'B'] = 10
1923+
>>> df.at[4, 'B']
1924+
10
18921925
1893-
Similarly to ``loc``, ``at`` provides **label** based scalar lookups.
1894-
You can also set using these indexers.
1926+
Get value within a Series
18951927
1928+
>>> df.loc[5].at['B']
1929+
4
1930+
1931+
Raises
1932+
------
1933+
KeyError
1934+
When label does not exist in DataFrame
18961935
"""
18971936

18981937
_takeable = False

0 commit comments

Comments
 (0)