From aa0804fdf378c29690312a9449089da053d3208e Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 00:22:54 +0530 Subject: [PATCH 01/17] DOC: Clarify parentheses vs. brackets usage (GH#62314) --- doc/source/getting_started/index.rst | 43 +++++ .../11_brackets_vs_parenthesis.rst | 151 ++++++++++++++++++ .../getting_started/intro_tutorials/index.rst | 1 + package-lock.json | 6 + 4 files changed, 201 insertions(+) create mode 100644 doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst create mode 100644 package-lock.json diff --git a/doc/source/getting_started/index.rst b/doc/source/getting_started/index.rst index a17699a71fbd3..d72c27929a25f 100644 --- a/doc/source/getting_started/index.rst +++ b/doc/source/getting_started/index.rst @@ -520,6 +520,49 @@ Data sets often contain more than just numerical data. pandas provides a wide ra :ref:`To user guide ` +.. raw:: html + + + + + + + +
+ +
+
+ +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 + +
+ + +:ref:`To introduction tutorial <10min_tut_11_brackets_vs_parenthesis>` + +.. raw:: html + + + + +:ref:`To user guide ` + .. raw:: html diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst new file mode 100644 index 0000000000000..208550ef20a9d --- /dev/null +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -0,0 +1,151 @@ +.. _10min_tut_11_brackets_vs_parenthesis: + +Parentheses vs. Square Brackets in Python and pandas +==================================================== + +Python and pandas use both **parentheses** ``()`` and **square brackets** ``[]``, but these have separate and important roles. Understanding their differences is essential for writing correct Python and pandas code. + +Overview of Bracket Usage +------------------------- + ++------------------------------------+-------------------------------+------------------------------+ +| Context | Parentheses ``()`` | Square Brackets ``[]`` | ++====================================+===============================+==============================+ +| Function and method calls | Yes: ``df.mean()`` | No | ++------------------------------------+-------------------------------+------------------------------+ +| Tuple creation | Yes: ``(a, b, c)`` | No | ++------------------------------------+-------------------------------+------------------------------+ +| List creation and item access | No | Yes: ``a[0]``, ``[1, 2]`` | ++------------------------------------+-------------------------------+------------------------------+ +| Dictionary item access | No | Yes: ``mydict['key']`` | ++------------------------------------+-------------------------------+------------------------------+ +| pandas column selection | No | Yes: ``df['A']``, | +| | | ``df[['A', 'B']]`` | ++------------------------------------+-------------------------------+------------------------------+ +| pandas row selection and slicing | No | Yes: ``df[0:5]``, | +| | | ``df.loc[2]`` | ++------------------------------------+-------------------------------+------------------------------+ +| Boolean indexing | No | Yes: ``df[df['col'] > 10]`` | ++------------------------------------+-------------------------------+------------------------------+ +| Grouping/logical expressions | Yes: ``(x + y) * z`` | No | ++------------------------------------+-------------------------------+------------------------------+ + +Detailed Explanations and Examples +---------------------------------- + +**Parentheses ``()``** + +- Used to *call* functions and methods, enclosing arguments: + .. code-block:: python + + df.mean() + print("Hello, world!") + sum([1, 2, 3]) + +- Used to create *tuples*, which are immutable ordered collections: + .. code-block:: python + + coordinates = (10, 20) + empty_tuple = () + +- Used for *grouping expressions* in mathematics and logic: + .. code-block:: python + + result = (1 + 2) * 3 + is_valid = (score > 0) and (score < 100) + +- Used to spread Python statements over multiple lines: + + .. code-block:: python + + total = ( + 1 + + 2 + + 3 + ) + +**Square Brackets ``[]``** + +- Used to *define* and *access* elements of Python lists: + .. code-block:: python + + numbers = [1, 2, 3, 4] + first = numbers[0] + sub = numbers[1:3] + +- Used to *access* values in dictionaries by key: + .. code-block:: python + + prices = {'apple': 40, 'banana': 10} + apple_price = prices['apple'] + +- Used for all kinds of *indexing* and *selection* in pandas DataFrames and Series: + + *Single column selection* (returns Series): + .. code-block:: python + + df['A'] + + *Multiple columns selection* (returns DataFrame): + .. code-block:: python + + df[['A', 'B']] + + Here, the inner brackets create a Python list of column labels, and the outer brackets are pandas selection syntax. + + *Row selection and slicing*: + .. code-block:: python + + df[0:2] # selects rows 0 and 1 by integer position + df.loc[2] # selects row with label/index 2 + df.iloc[2] # selects row at integer position 2 + + *Boolean indexing (row filtering)*: + .. code-block:: python + + df[df['A'] > 5] # returns only rows where column 'A' is greater than 5 + +Key Points to Remember +---------------------- + +- **Parentheses** are for function/method calls, tuple creation, grouping, and continuation of statements. +- **Square brackets** are for creating and accessing lists, dictionary values, slicing sequences, and—critically for pandas—selecting/subsetting columns and rows. +- In pandas, *single* square brackets select a single column as a Series (``df['A']``), while *double* square brackets select multiple columns as a DataFrame (``df[['A', 'B']]``) because the *inner brackets create a Python list* of column labels. +- Boolean indexing in pandas always uses square brackets enclosing a boolean Series: ``df[df['A'] > 5]``. + +Common Pitfalls +--------------- + +- Attempting to use parentheses for list/tensor/column access or slicing will result in errors. +- Using single brackets with a list inside (like ``df[['A']]``) still returns a DataFrame, not a Series—bracket count and the type of object inside matters. +- Remember that method calls (like ``df.mean()`` or ``df.groupby('A')``) always require parentheses, even if there are no arguments. + +Example Summary +--------------- + +.. code-block:: python + + import pandas as pd + df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) + + # Function and method calls + df.mean() + + # Tuple creation + t = (1, 2, 3) + + # List creation/access + mylist = [10, 20, 30] + first_item = mylist[0] + + # pandas column selection + df['A'] + df[['A', 'B']] + + # pandas boolean indexing + df[df['B'] > 4] + + # Grouping/logical expressions + selected = (df['A'] > 1) & (df['B'] < 6) + +Getting comfortable with the distinction between parentheses and square brackets is a major milestone for every new pandas user. This understanding leads to correct code and enhanced productivity when working in both core Python and pandas. diff --git a/doc/source/getting_started/intro_tutorials/index.rst b/doc/source/getting_started/intro_tutorials/index.rst index c67e18043c175..4968908366359 100644 --- a/doc/source/getting_started/intro_tutorials/index.rst +++ b/doc/source/getting_started/intro_tutorials/index.rst @@ -19,3 +19,4 @@ Getting started tutorials 08_combine_dataframes 09_timeseries 10_text_data + 11_brackets_vs_parenthesis diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000000..bb3c8e31ba2f5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "pandas", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From ada92d728bab01fdb2300922bc7ac0b34130e711 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 22:10:58 +0530 Subject: [PATCH 02/17] DOC: Clarify parentheses vs. brackets usage (GH#62314) updated --- .../11_brackets_vs_parenthesis.rst | 147 +----------------- 1 file changed, 1 insertion(+), 146 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index 208550ef20a9d..2ec6d804406b0 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -3,149 +3,4 @@ Parentheses vs. Square Brackets in Python and pandas ==================================================== -Python and pandas use both **parentheses** ``()`` and **square brackets** ``[]``, but these have separate and important roles. Understanding their differences is essential for writing correct Python and pandas code. - -Overview of Bracket Usage -------------------------- - -+------------------------------------+-------------------------------+------------------------------+ -| Context | Parentheses ``()`` | Square Brackets ``[]`` | -+====================================+===============================+==============================+ -| Function and method calls | Yes: ``df.mean()`` | No | -+------------------------------------+-------------------------------+------------------------------+ -| Tuple creation | Yes: ``(a, b, c)`` | No | -+------------------------------------+-------------------------------+------------------------------+ -| List creation and item access | No | Yes: ``a[0]``, ``[1, 2]`` | -+------------------------------------+-------------------------------+------------------------------+ -| Dictionary item access | No | Yes: ``mydict['key']`` | -+------------------------------------+-------------------------------+------------------------------+ -| pandas column selection | No | Yes: ``df['A']``, | -| | | ``df[['A', 'B']]`` | -+------------------------------------+-------------------------------+------------------------------+ -| pandas row selection and slicing | No | Yes: ``df[0:5]``, | -| | | ``df.loc[2]`` | -+------------------------------------+-------------------------------+------------------------------+ -| Boolean indexing | No | Yes: ``df[df['col'] > 10]`` | -+------------------------------------+-------------------------------+------------------------------+ -| Grouping/logical expressions | Yes: ``(x + y) * z`` | No | -+------------------------------------+-------------------------------+------------------------------+ - -Detailed Explanations and Examples ----------------------------------- - -**Parentheses ``()``** - -- Used to *call* functions and methods, enclosing arguments: - .. code-block:: python - - df.mean() - print("Hello, world!") - sum([1, 2, 3]) - -- Used to create *tuples*, which are immutable ordered collections: - .. code-block:: python - - coordinates = (10, 20) - empty_tuple = () - -- Used for *grouping expressions* in mathematics and logic: - .. code-block:: python - - result = (1 + 2) * 3 - is_valid = (score > 0) and (score < 100) - -- Used to spread Python statements over multiple lines: - - .. code-block:: python - - total = ( - 1 + - 2 + - 3 - ) - -**Square Brackets ``[]``** - -- Used to *define* and *access* elements of Python lists: - .. code-block:: python - - numbers = [1, 2, 3, 4] - first = numbers[0] - sub = numbers[1:3] - -- Used to *access* values in dictionaries by key: - .. code-block:: python - - prices = {'apple': 40, 'banana': 10} - apple_price = prices['apple'] - -- Used for all kinds of *indexing* and *selection* in pandas DataFrames and Series: - - *Single column selection* (returns Series): - .. code-block:: python - - df['A'] - - *Multiple columns selection* (returns DataFrame): - .. code-block:: python - - df[['A', 'B']] - - Here, the inner brackets create a Python list of column labels, and the outer brackets are pandas selection syntax. - - *Row selection and slicing*: - .. code-block:: python - - df[0:2] # selects rows 0 and 1 by integer position - df.loc[2] # selects row with label/index 2 - df.iloc[2] # selects row at integer position 2 - - *Boolean indexing (row filtering)*: - .. code-block:: python - - df[df['A'] > 5] # returns only rows where column 'A' is greater than 5 - -Key Points to Remember ----------------------- - -- **Parentheses** are for function/method calls, tuple creation, grouping, and continuation of statements. -- **Square brackets** are for creating and accessing lists, dictionary values, slicing sequences, and—critically for pandas—selecting/subsetting columns and rows. -- In pandas, *single* square brackets select a single column as a Series (``df['A']``), while *double* square brackets select multiple columns as a DataFrame (``df[['A', 'B']]``) because the *inner brackets create a Python list* of column labels. -- Boolean indexing in pandas always uses square brackets enclosing a boolean Series: ``df[df['A'] > 5]``. - -Common Pitfalls ---------------- - -- Attempting to use parentheses for list/tensor/column access or slicing will result in errors. -- Using single brackets with a list inside (like ``df[['A']]``) still returns a DataFrame, not a Series—bracket count and the type of object inside matters. -- Remember that method calls (like ``df.mean()`` or ``df.groupby('A')``) always require parentheses, even if there are no arguments. - -Example Summary ---------------- - -.. code-block:: python - - import pandas as pd - df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) - - # Function and method calls - df.mean() - - # Tuple creation - t = (1, 2, 3) - - # List creation/access - mylist = [10, 20, 30] - first_item = mylist[0] - - # pandas column selection - df['A'] - df[['A', 'B']] - - # pandas boolean indexing - df[df['B'] > 4] - - # Grouping/logical expressions - selected = (df['A'] > 1) & (df['B'] < 6) - -Getting comfortable with the distinction between parentheses and square brackets is a major milestone for every new pandas user. This understanding leads to correct code and enhanced productivity when working in both core Python and pandas. +In Python and pandas, parentheses ``()`` and square brackets ``[]`` have distinct uses, which can sometimes be confusing for new users. Parentheses are used to call functions and methods (for example, ``df.mean()``), to group expressions in calculations (such as ``(a + b) * c``), and to create tuples. Square brackets, on the other hand, are used for defining lists and for indexing or selecting data—in both core Python and pandas. For example, ``df['A']`` selects column ``A`` from a DataFrame, and ``df[0:3]`` selects rows by position. In pandas, square brackets are always used when you want to select or filter data, while parentheses are used any time you are calling a method or function. Remember: use ``[]`` for selection or indexing, and ``()`` for function calls and grouping. From 41272b95f727eff306462db68c32d775ff7df307 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 22:13:44 +0530 Subject: [PATCH 03/17] DOC: Clarify parentheses vs. brackets usage (GH#62314) updated --- .../intro_tutorials/11_brackets_vs_parenthesis.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index 2ec6d804406b0..c89e132c3c3a9 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -1,6 +1,7 @@ -.. _10min_tut_11_brackets_vs_parenthesis: +In both Python and pandas, it’s important to understand the difference between parentheses ``()`` and square brackets ``[]``: -Parentheses vs. Square Brackets in Python and pandas -==================================================== +- **Parentheses** are used to call functions and methods. For example, ``df.mean()`` calculates the mean of a DataFrame, and 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]``. -In Python and pandas, parentheses ``()`` and square brackets ``[]`` have distinct uses, which can sometimes be confusing for new users. Parentheses are used to call functions and methods (for example, ``df.mean()``), to group expressions in calculations (such as ``(a + b) * c``), and to create tuples. Square brackets, on the other hand, are used for defining lists and for indexing or selecting data—in both core Python and pandas. For example, ``df['A']`` selects column ``A`` from a DataFrame, and ``df[0:3]`` selects rows by position. In pandas, square brackets are always used when you want to select or filter data, while parentheses are used any time you are calling a method or function. Remember: use ``[]`` for selection or indexing, and ``()`` for function calls and grouping. +Remember: +**Use [] for selection or indexing, and () for calling functions or grouping expressions.** From 8c77d05b87c9b6593cdf171e119d0dc74bccb461 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 22:22:19 +0530 Subject: [PATCH 04/17] DOC: Clarify parentheses vs. brackets usage (GH#62314) updated --- .../intro_tutorials/11_brackets_vs_parenthesis.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index c89e132c3c3a9..b361a32775d49 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -1,7 +1,15 @@ -In both Python and pandas, it’s important to understand the difference between parentheses ``()`` and square brackets ``[]``: +.. _10min_tut_11_brackets_vs_parenthesis: + +Parentheses vs. Square Brackets in Python and pandas +==================================================== + +In both Python and pandas, it’s 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, and 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.** +**Use ``[]`` for selection or indexing, and ``()`` for calling functions or grouping expressions.** + +For more explanation, see `Brackets in Python and pandas `__. + From fac8e7c521e48d9c714420b7c44d4d31b27f2655 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 22:27:48 +0530 Subject: [PATCH 05/17] DOC: Clarify parentheses vs. brackets usage (GH#62314) updated --- .../intro_tutorials/11_brackets_vs_parenthesis.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index b361a32775d49..73bc3b5aa2a57 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -3,13 +3,13 @@ Parentheses vs. Square Brackets in Python and pandas ==================================================== -In both Python and pandas, it’s important to understand the difference between parentheses (``()``) and square brackets (``[]``): +In both Python and pandas, it’s 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, and 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.** +**Use [] for selection or indexing, and () for calling functions or grouping expressions.** For more explanation, see `Brackets in Python and pandas `__. From 689b069bc80a6b4dc85c8a9db1eb86c072c133e0 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 22:34:36 +0530 Subject: [PATCH 06/17] DOC: Fix trailing whitespace and end-of-file issues (pre-commit CI) --- .../intro_tutorials/11_brackets_vs_parenthesis.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index 73bc3b5aa2a57..da0874098a0a9 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -2,7 +2,6 @@ Parentheses vs. Square Brackets in Python and pandas ==================================================== - In both Python and pandas, it’s 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, and parentheses are also used to group expressions, such as ``(a + b) * c``, or to create tuples: ``(1, 2, 3)``. @@ -11,5 +10,4 @@ In both Python and pandas, it’s important to understand the difference between Remember: **Use [] for selection or indexing, and () for calling functions or grouping expressions.** -For more explanation, see `Brackets in Python and pandas `__. - +For more explanation, see `Brackets in Python and pandas `__. \ No newline at end of file From a1feaabad38c852732e219f43894c0e7c1fb8306 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 23:03:06 +0530 Subject: [PATCH 07/17] DOC: Fix trailing whitespace and end-of-file issues (pre-commit CI) --- .../intro_tutorials/11_brackets_vs_parenthesis.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index da0874098a0a9..f751165c57cb6 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -2,12 +2,14 @@ Parentheses vs. Square Brackets in Python and pandas ==================================================== -In both Python and pandas, it’s 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, and parentheses are also used to group expressions, such as ``(a + b) * c``, or to create tuples: ``(1, 2, 3)``. +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 `__. \ No newline at end of file +**Remember :** +Use ``[]`` for selection or indexing, and ``()`` for calling functions or grouping expressions. + +For more explanation, see `Brackets in Python and pandas `__. From 2c658b182634d3af7a8e25feb92dad48b2c0122e Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 23:15:22 +0530 Subject: [PATCH 08/17] DOC: Fix trailing whitespace and end-of-file issues (pre-commit CI) --- .../11_brackets_vs_parenthesis.rst | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index f751165c57cb6..b32d2b152bc65 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -1,15 +1 @@ -.. _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 `__. +.. _10min_tut_11_brackets_vs_parenthesis:\n\nParentheses vs. Square Brackets in Python and pandas\n====================================================\n\nIn both Python and pandas, it is important to understand the difference between parentheses ``()`` and square brackets ``[]``:\n\n- **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)``.\n- **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]``.\n\n\n**Remember :**\nUse ``[]`` for selection or indexing, and ``()`` for calling functions or grouping expressions.\n\nFor more explanation, see `Brackets in Python and pandas `__.\n \ No newline at end of file From cf1e39505bb90a7f63ddeb436f189c453ea8b061 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Tue, 16 Sep 2025 23:19:14 +0530 Subject: [PATCH 09/17] DOC: Fix trailing whitespace and end-of-file issues (pre-commit CI) --- .../intro_tutorials/11_brackets_vs_parenthesis.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst index b32d2b152bc65..55fb909e647f0 100644 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -1 +1,13 @@ -.. _10min_tut_11_brackets_vs_parenthesis:\n\nParentheses vs. Square Brackets in Python and pandas\n====================================================\n\nIn both Python and pandas, it is important to understand the difference between parentheses ``()`` and square brackets ``[]``:\n\n- **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)``.\n- **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]``.\n\n\n**Remember :**\nUse ``[]`` for selection or indexing, and ``()`` for calling functions or grouping expressions.\n\nFor more explanation, see `Brackets in Python and pandas `__.\n \ No newline at end of file +.. _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 `__. From 0aa476a582febc6e2aa230b43d41f2b98b9b0244 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Wed, 17 Sep 2025 22:08:45 +0530 Subject: [PATCH 10/17] DOC: Changed 03_subset_data.rst --- .../intro_tutorials/03_subset_data.rst | 2 ++ .../intro_tutorials/11_brackets_vs_parenthesis.rst | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst diff --git a/doc/source/getting_started/intro_tutorials/03_subset_data.rst b/doc/source/getting_started/intro_tutorials/03_subset_data.rst index ced976f680885..9805e3b6e995b 100644 --- a/doc/source/getting_started/intro_tutorials/03_subset_data.rst +++ b/doc/source/getting_started/intro_tutorials/03_subset_data.rst @@ -54,6 +54,8 @@ I’m interested in the age of the Titanic passengers. To select a single column, use square brackets ``[]`` with the column name of the column of interest. +For more explanation, see `Brackets in Python and pandas `__. + .. raw:: html diff --git a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst deleted file mode 100644 index 55fb909e647f0..0000000000000 --- a/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _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 `__. From b04d3a49d8385870eeefb44704d1df55f3b5814a Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Wed, 17 Sep 2025 22:38:01 +0530 Subject: [PATCH 11/17] warning resolved --- doc/source/getting_started/index.rst | 41 ------------------- .../getting_started/intro_tutorials/index.rst | 3 +- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/doc/source/getting_started/index.rst b/doc/source/getting_started/index.rst index d72c27929a25f..78fe09e9164d8 100644 --- a/doc/source/getting_started/index.rst +++ b/doc/source/getting_started/index.rst @@ -528,48 +528,7 @@ Data sets often contain more than just numerical data. pandas provides a wide ra
-
- -
-
- -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 - -
- - -:ref:`To introduction tutorial <10min_tut_11_brackets_vs_parenthesis>` - -.. raw:: html - - - - -:ref:`To user guide ` - -.. raw:: html - - -
-
-
-
diff --git a/doc/source/getting_started/intro_tutorials/index.rst b/doc/source/getting_started/intro_tutorials/index.rst index 4968908366359..5eadd3e692f96 100644 --- a/doc/source/getting_started/intro_tutorials/index.rst +++ b/doc/source/getting_started/intro_tutorials/index.rst @@ -18,5 +18,4 @@ Getting started tutorials 07_reshape_table_layout 08_combine_dataframes 09_timeseries - 10_text_data - 11_brackets_vs_parenthesis + 10_text_data \ No newline at end of file From 6c8134601caa4653005a00d4bccc78a0e0777a9b Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Wed, 17 Sep 2025 22:44:27 +0530 Subject: [PATCH 12/17] ci precommit --- doc/source/getting_started/intro_tutorials/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/getting_started/intro_tutorials/index.rst b/doc/source/getting_started/intro_tutorials/index.rst index 5eadd3e692f96..4470bcea555e1 100644 --- a/doc/source/getting_started/intro_tutorials/index.rst +++ b/doc/source/getting_started/intro_tutorials/index.rst @@ -18,4 +18,5 @@ Getting started tutorials 07_reshape_table_layout 08_combine_dataframes 09_timeseries - 10_text_data \ No newline at end of file + 10_text_data + \ No newline at end of file From 2ed7630664c2c1875a9fa4afd06ebca00f3b4a86 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Wed, 17 Sep 2025 23:44:02 +0530 Subject: [PATCH 13/17] ci precommit --- doc/source/getting_started/index.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/getting_started/index.rst b/doc/source/getting_started/index.rst index 78fe09e9164d8..0fc132486c318 100644 --- a/doc/source/getting_started/index.rst +++ b/doc/source/getting_started/index.rst @@ -527,9 +527,6 @@ Data sets often contain more than just numerical data. pandas provides a wide ra - - - From 6aeeabd273168720ae6c4a971802b148e1a49e86 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Thu, 18 Sep 2025 00:34:10 +0530 Subject: [PATCH 14/17] ci precommit --- doc/source/getting_started/intro_tutorials/03_subset_data.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/source/getting_started/intro_tutorials/03_subset_data.rst b/doc/source/getting_started/intro_tutorials/03_subset_data.rst index 9805e3b6e995b..ced976f680885 100644 --- a/doc/source/getting_started/intro_tutorials/03_subset_data.rst +++ b/doc/source/getting_started/intro_tutorials/03_subset_data.rst @@ -54,8 +54,6 @@ I’m interested in the age of the Titanic passengers. To select a single column, use square brackets ``[]`` with the column name of the column of interest. -For more explanation, see `Brackets in Python and pandas `__. - .. raw:: html From 08f3efd05c096061c8c20d6046e99eb20c9f683c Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Thu, 18 Sep 2025 00:46:43 +0530 Subject: [PATCH 15/17] ci precommit --- doc/source/getting_started/intro_tutorials/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/getting_started/intro_tutorials/index.rst b/doc/source/getting_started/intro_tutorials/index.rst index 4470bcea555e1..c67e18043c175 100644 --- a/doc/source/getting_started/intro_tutorials/index.rst +++ b/doc/source/getting_started/intro_tutorials/index.rst @@ -19,4 +19,3 @@ Getting started tutorials 08_combine_dataframes 09_timeseries 10_text_data - \ No newline at end of file From 0fc545c2d5075250c0c4d07881db6ecadbcbe77e Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Thu, 18 Sep 2025 00:56:36 +0530 Subject: [PATCH 16/17] ci precommit --- doc/source/getting_started/intro_tutorials/03_subset_data.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/getting_started/intro_tutorials/03_subset_data.rst b/doc/source/getting_started/intro_tutorials/03_subset_data.rst index ced976f680885..9805e3b6e995b 100644 --- a/doc/source/getting_started/intro_tutorials/03_subset_data.rst +++ b/doc/source/getting_started/intro_tutorials/03_subset_data.rst @@ -54,6 +54,8 @@ I’m interested in the age of the Titanic passengers. To select a single column, use square brackets ``[]`` with the column name of the column of interest. +For more explanation, see `Brackets in Python and pandas `__. + .. raw:: html From 196a13360eee805107a792322d0f63d1f9516f84 Mon Sep 17 00:00:00 2001 From: AnandMukherjee2004 Date: Fri, 19 Sep 2025 22:01:45 +0530 Subject: [PATCH 17/17] remove accidentally committed package-lock.json --- package-lock.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index bb3c8e31ba2f5..0000000000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "pandas", - "lockfileVersion": 3, - "requires": true, - "packages": {} -}