Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/source/_static/schemas/01_dataframe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions doc/source/getting_started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,49 @@ Data sets often contain more than just numerical data. pandas provides a wide ra

:ref:`To user guide <text>`

.. raw:: html

</span>
</div>
</div>
</div>
</div>

<div class="card tutorial-card">
<div class="card-header collapsed card-link" data-bs-toggle="collapse" data-bs-target="#collapseEleven">
<div class="d-flex flex-row tutorial-card-header-1">
<div class="d-flex flex-row tutorial-card-header-2">
<button class="btn btn-dark btn-sm"></button>
How to use parentheses vs square brackets?
</div>
<span class="badge gs-badge-link">

:ref:`Straight to tutorial...<10min_tut_11_brackets_vs_parenthesis>`

.. raw:: html

</span>
</div>
</div>
<div id="collapseEleven" class="collapse" data-parent="#accordion">
<div class="card-body">

Understanding the difference between parentheses and square brackets is crucial for pandas users. Parentheses are used for function calls and grouping, while square brackets are for indexing and selection.

.. raw:: html

<div class="d-flex flex-row">
<span class="badge gs-badge-link">

:ref:`To introduction tutorial <10min_tut_11_brackets_vs_parenthesis>`

.. raw:: html

</span>
<span class="badge gs-badge-link">

:ref:`To user guide <indexing>`

.. raw:: html

</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ documentation.
pandas data table representation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. image:: ../../_static/schemas/01_table_dataframe.svg
.. image:: ../../_static/schemas/01_dataframe.svg
:align: center

.. raw:: html
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. _10min_tut_11_brackets_vs_parenthesis:

Parentheses vs. Square Brackets in Python and pandas
====================================================

In both Python and pandas, it is important to understand the difference between parentheses ``()`` and square brackets ``[]``:

- **Parentheses** are used to call functions and methods. For example, ``df.mean()`` calculates the mean of a DataFrame. Parentheses are also used to group expressions, such as ``(a + b) * c``, or to create tuples: ``(1, 2, 3)``.
- **Square brackets** are used for indexing, selecting data, and defining lists. In pandas, you use square brackets to select columns or filter data—for instance, ``df['A']`` selects column ``A``, while ``df[0:3]`` selects rows by position. In standard Python, square brackets are also used to define a list, as in ``my_list = [1, 2, 3]``.

Remember: Use ``[]`` for selection or indexing, and ``()`` for calling functions or grouping expressions.

For more explanation, see `Brackets in Python and pandas <https://python-public-policy.afeld.me/en/columbia/brackets.html>`__.
1 change: 1 addition & 0 deletions doc/source/getting_started/intro_tutorials/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Getting started tutorials
08_combine_dataframes
09_timeseries
10_text_data
11_brackets_vs_parenthesis
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading