Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98b6ac6

Browse files
committed
update for class
1 parent715a072 commit98b6ac6

File tree

1 file changed

+3
-98
lines changed

1 file changed

+3
-98
lines changed

‎lectures/07-pandas/pandas-babynames.ipynb‎

Lines changed: 3 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -6615,105 +6615,10 @@
66156615
},
66166616
{
66176617
"cell_type":"code",
6618-
"execution_count":31,
6618+
"execution_count":null,
66196619
"metadata": {},
6620-
"outputs": [
6621-
{
6622-
"name":"stderr",
6623-
"output_type":"stream",
6624-
"text": [
6625-
"/home/zingale/.local/lib/python3.6/site-packages/ipykernel_launcher.py:5: FutureWarning: 'year' is both a column name and an index level.\n",
6626-
"Defaulting to column but this will raise an ambiguity error in a future version\n",
6627-
"\"\"\"\n",
6628-
"/home/zingale/.local/lib/python3.6/site-packages/ipykernel_launcher.py:5: FutureWarning: 'sex' is both a column name and an index level.\n",
6629-
"Defaulting to column but this will raise an ambiguity error in a future version\n",
6630-
"\"\"\"\n"
6631-
]
6632-
},
6633-
{
6634-
"data": {
6635-
"text/html": [
6636-
"<div>\n",
6637-
"<style>\n",
6638-
" .dataframe thead tr:only-child th {\n",
6639-
" text-align: right;\n",
6640-
" }\n",
6641-
"\n",
6642-
" .dataframe thead th {\n",
6643-
" text-align: left;\n",
6644-
" }\n",
6645-
"\n",
6646-
" .dataframe tbody tr th {\n",
6647-
" vertical-align: top;\n",
6648-
" }\n",
6649-
"</style>\n",
6650-
"<table border=\"1\" class=\"dataframe\">\n",
6651-
" <thead>\n",
6652-
" <tr style=\"text-align: right;\">\n",
6653-
" <th>sex</th>\n",
6654-
" <th>F</th>\n",
6655-
" <th>M</th>\n",
6656-
" </tr>\n",
6657-
" <tr>\n",
6658-
" <th>year</th>\n",
6659-
" <th></th>\n",
6660-
" <th></th>\n",
6661-
" </tr>\n",
6662-
" </thead>\n",
6663-
" <tbody>\n",
6664-
" <tr>\n",
6665-
" <th>1880</th>\n",
6666-
" <td>38</td>\n",
6667-
" <td>14</td>\n",
6668-
" </tr>\n",
6669-
" <tr>\n",
6670-
" <th>1881</th>\n",
6671-
" <td>38</td>\n",
6672-
" <td>14</td>\n",
6673-
" </tr>\n",
6674-
" <tr>\n",
6675-
" <th>1882</th>\n",
6676-
" <td>38</td>\n",
6677-
" <td>15</td>\n",
6678-
" </tr>\n",
6679-
" <tr>\n",
6680-
" <th>1883</th>\n",
6681-
" <td>39</td>\n",
6682-
" <td>15</td>\n",
6683-
" </tr>\n",
6684-
" <tr>\n",
6685-
" <th>1884</th>\n",
6686-
" <td>39</td>\n",
6687-
" <td>16</td>\n",
6688-
" </tr>\n",
6689-
" </tbody>\n",
6690-
"</table>\n",
6691-
"</div>"
6692-
],
6693-
"text/plain": [
6694-
"sex F M\n",
6695-
"year\n",
6696-
"1880 38 14\n",
6697-
"1881 38 14\n",
6698-
"1882 38 15\n",
6699-
"1883 39 15\n",
6700-
"1884 39 16"
6701-
]
6702-
},
6703-
"execution_count":31,
6704-
"metadata": {},
6705-
"output_type":"execute_result"
6706-
}
6707-
],
6708-
"source": [
6709-
"def get_count(group, q=0.5):\n",
6710-
" group = group.sort_values(by=\"prop\", ascending=False)\n",
6711-
" return group[\"prop\"].cumsum().searchsorted(0.5)[0] + 1\n",
6712-
"\n",
6713-
"diversity = top.groupby([\"year\",\"sex\"]).apply(get_count)\n",
6714-
"diversity = diversity.unstack(\"sex\")\n",
6715-
"diversity.head()"
6716-
]
6620+
"outputs": [],
6621+
"source": []
67176622
},
67186623
{
67196624
"cell_type":"code",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp