Access a single value for a row/column label pair. Similar to ``loc``, in that both provide label-based lookups. Use ``at`` if you only need to get or set a single value in a DataFrame or Series. Raises ------ KeyError If getting
(self)
| 634 | |
| 635 | @property |
| 636 | def at(self) -> _AtIndexer: |
| 637 | """ |
| 638 | Access a single value for a row/column label pair. |
| 639 | |
| 640 | Similar to ``loc``, in that both provide label-based lookups. Use |
| 641 | ``at`` if you only need to get or set a single value in a DataFrame |
| 642 | or Series. |
| 643 | |
| 644 | Raises |
| 645 | ------ |
| 646 | KeyError |
| 647 | If getting a value and 'label' does not exist in a DataFrame or Series. |
| 648 | |
| 649 | ValueError |
| 650 | If row/column label pair is not a tuple or if any label |
| 651 | from the pair is not a scalar for DataFrame. |
| 652 | If label is list-like (*excluding* NamedTuple) for Series. |
| 653 | |
| 654 | See Also |
| 655 | -------- |
| 656 | DataFrame.at : Access a single value for a row/column pair by label. |
| 657 | DataFrame.iat : Access a single value for a row/column pair by integer |
| 658 | position. |
| 659 | DataFrame.loc : Access a group of rows and columns by label(s). |
| 660 | DataFrame.iloc : Access a group of rows and columns by integer |
| 661 | position(s). |
| 662 | Series.at : Access a single value by label. |
| 663 | Series.iat : Access a single value by integer position. |
| 664 | Series.loc : Access a group of rows by label(s). |
| 665 | Series.iloc : Access a group of rows by integer position(s). |
| 666 | |
| 667 | Notes |
| 668 | ----- |
| 669 | See :ref:`Fast scalar value getting and setting <indexing.basics.get_value>` |
| 670 | for more details. |
| 671 | |
| 672 | Examples |
| 673 | -------- |
| 674 | >>> df = pd.DataFrame( |
| 675 | ... [[0, 2, 3], [0, 4, 1], [10, 20, 30]], |
| 676 | ... index=[4, 5, 6], |
| 677 | ... columns=["A", "B", "C"], |
| 678 | ... ) |
| 679 | >>> df |
| 680 | A B C |
| 681 | 4 0 2 3 |
| 682 | 5 0 4 1 |
| 683 | 6 10 20 30 |
| 684 | |
| 685 | Get value at specified row/column pair |
| 686 | |
| 687 | >>> df.at[4, "B"] |
| 688 | np.int64(2) |
| 689 | |
| 690 | Set value at specified row/column pair |
| 691 | |
| 692 | >>> df.at[4, "B"] = 10 |
| 693 | >>> df.at[4, "B"] |