diff --git a/pandas-intro/pandas_intro.ipynb b/pandas-intro/pandas_intro.ipynb index 47391317ec..1ed81e7fe4 100644 --- a/pandas-intro/pandas_intro.ipynb +++ b/pandas-intro/pandas_intro.ipynb @@ -33,7 +33,7 @@ "metadata": {}, "source": [ "```console\n", - "$ python3 -m pip install requests pandas matplotlib\n", + "$ python3 -m pip install \"requests==2.34.*\" \"pandas==3.1.*\" \"matplotlib==3.11.*\"\n", "```" ] }, @@ -61,7 +61,10 @@ "source": [ "import requests\n", "\n", - "download_url = \"https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-elo/nbaallelo.csv\"\n", + "download_url = (\n", + " \"https://raw.githubusercontent.com/fivethirtyeight/\"\n", + " \"data/master/nba-elo/nbaallelo.csv\"\n", + ")\n", "target_csv_path = \"nba_all_elo.csv\"\n", "\n", "response = requests.get(download_url)\n", @@ -197,7 +200,7 @@ "metadata": {}, "outputs": [], "source": [ - "nba.describe(include=object)" + "nba.describe(include=\"str\")" ] }, { @@ -215,11 +218,13 @@ "source": [ "nba[\"team_id\"].value_counts()\n", "# Expected:\n", + "# team_id\n", "# BOS 5997\n", "# NYK 5769\n", "# LAL 5078\n", "\n", - "# SDS 11" + "# SDS 11\n", + "# Name: count, Length: 104, dtype: int64" ] }, { @@ -230,12 +235,13 @@ "source": [ "nba[\"fran_id\"].value_counts()\n", "# Expected:\n", + "# fran_id\n", "# Lakers 6024\n", "# Celtics 5997\n", "# Knicks 5769\n", "\n", "# Falcons 60\n", - "# Name: fran_id, dtype: int64" + "# Name: count, dtype: int64" ] }, { @@ -598,29 +604,7 @@ "source": [ "city_revenues[\"Toronto\"]\n", "# Expected:\n", - "# 8000" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "city_revenues[1]\n", - "# Expected:\n", - "# 8000" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "city_revenues[-1]\n", - "# Expected:\n", - "# 6500" + "# np.int64(8000)" ] }, { @@ -1330,7 +1314,9 @@ "outputs": [], "source": [ "data_with_default_notes = nba.copy()\n", - "data_with_default_notes[\"notes\"].fillna(value=\"no notes at all\", inplace=True)\n", + "data_with_default_notes[\"notes\"] = data_with_default_notes[\"notes\"].fillna(\n", + " value=\"no notes at all\"\n", + ")\n", "data_with_default_notes[\"notes\"].describe()\n", "# Expected:\n", "# count 126314\n",