Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion doc/source/user_guide/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind confirming I have this right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pandas allows strings that pass isidentifier https://docs.python.org/3/library/stdtypes.html#str.isidentifier

alternatively use the column name attribute:

.. 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
Expand Down
Loading