Skip to content
Open
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
44 changes: 15 additions & 29 deletions pandas-intro/pandas_intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"```"
]
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -197,7 +200,7 @@
"metadata": {},
"outputs": [],
"source": [
"nba.describe(include=object)"
"nba.describe(include=\"str\")"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down
Loading