Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand on different Getitem uses #60806

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Member 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 dot notation:
Copy link
Member Author

Choose a reason for hiding this comment

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

Is "dot notation" the right term?

Copy link
Member

Choose a reason for hiding this comment

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

Get attribute (getattr) notation would be more correct


.. 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