Skip to content

Commit 3b42783

Browse files
committed
Update Pandas_walkthrough.ipynb
1 parent 9e85882 commit 3b42783

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

notebooks/Pandas_walkthrough.ipynb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,6 @@
982982
]
983983
},
984984
{
985-
"attachments": {},
986985
"cell_type": "markdown",
987986
"metadata": {},
988987
"source": [
@@ -993,7 +992,17 @@
993992
">new_df = df.loc[:, ['CO_eclogite', 'CO_granulite', 'CO_pyroxenite']] ❌ \n",
994993
">new_df = df.loc[:, ['CO_eclogite', 'CO_granulite', 'CO_pyroxenite']].copy() ✅ \n",
995994
">```\n",
996-
"> ⚠️ Beware! Contrary to regular Python or Numpy, the Pandas ``.loc`` method **includes** the index stop point so that ``df.loc[0:2]`` is equivalent to ``array[0:3]``"
995+
"> ⚠️ Beware! Contrary to regular Python or Numpy, the Pandas ``.loc`` method **includes** the index stop point so that ``df.loc[0:2]`` is equivalent to ``array[0:3]``\n",
996+
"\n",
997+
"\n",
998+
"If you want to extract a single value from a Pandas DataFrame as a plain Python data type (e.g. a float), the best practice is to use the ``.at[]`` or ``.iat[]`` method. The difference between the two is that ``.at[]`` is optimised for scalar lookups by label (as in the ``.loc`` method) while ``.iat[]`` is optimised for scalar lookup by integer position (as in the ``.iloc`` method).\n",
999+
"\n",
1000+
"| method | what for |\n",
1001+
"| -------------- | ------------------------------------------------------------ |\n",
1002+
"| DataFrame.at | Access a single value for a row/column pair by label. |\n",
1003+
"| DataFrame.iat | Access a single value for a row/column pair by integer position. |\n",
1004+
"| DataFrame.loc | Access a group of rows and columns by label(s). |\n",
1005+
"| DataFrame.iloc | Access a group of rows and columns by integer position(s). |"
9971006
]
9981007
},
9991008
{

0 commit comments

Comments
 (0)