From 8b6c64e86f8cb2fee8456b267fd3e712fecb0c57 Mon Sep 17 00:00:00 2001 From: Aidan Feldman Date: Tue, 28 Jan 2025 00:45:34 -0500 Subject: [PATCH] expand on different Getitem uses --- doc/source/user_guide/10min.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/10min.rst b/doc/source/user_guide/10min.rst index 72bb93d21a99f..5355427e0cdef 100644 --- a/doc/source/user_guide/10min.rst +++ b/doc/source/user_guide/10min.rst @@ -178,12 +178,26 @@ Getitem (``[]``) ~~~~~~~~~~~~~~~~ For a :class:`DataFrame`, passing a single label selects a column and -yields a :class:`Series` equivalent to ``df.A``: +yields a :class:`Series`: .. ipython:: python df["A"] +If the label only contains letters, numbers, and underscores, you can +alternatively use dot notation: + +.. ipython:: python + + df.A + +Passing a list of column labels selects multiple columns, which can be useful +for getting a subset/rearranging: + +.. ipython:: python + + df[["B", "A"]] + For a :class:`DataFrame`, passing a slice ``:`` selects matching rows: .. ipython:: python