diff --git a/doc/source/_static/schemas/01_dataframe.svg b/doc/source/_static/schemas/01_dataframe.svg new file mode 100644 index 0000000000000..49f9fc426e84a --- /dev/null +++ b/doc/source/_static/schemas/01_dataframe.svg @@ -0,0 +1 @@ + \ No newline at end of file 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/01_table_oriented.rst b/doc/source/getting_started/intro_tutorials/01_table_oriented.rst index 7e86ad6c499d9..d4504df20948a 100644 --- a/doc/source/getting_started/intro_tutorials/01_table_oriented.rst +++ b/doc/source/getting_started/intro_tutorials/01_table_oriented.rst @@ -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 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..55fb909e647f0 --- /dev/null +++ b/doc/source/getting_started/intro_tutorials/11_brackets_vs_parenthesis.rst @@ -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 `__. 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": {} +}