Skip to content

Commit

Permalink
update pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
luweizheng committed Nov 29, 2023
1 parent f0fe65d commit 43bfae8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 78 deletions.
1 change: 1 addition & 0 deletions ch-pandas/dataframe-merge-concat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"\n",
"```{figure} ../img/ch-pandas/merge.svg\n",
"---\n",
"width: 500px\n",
"name: merge-img\n",
"---\n",
"对两个 DataFrame 进行 merge 操作\n",
Expand Down
60 changes: 26 additions & 34 deletions ch-pandas/dataframe-pivot-melt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 34,
"metadata": {
"tags": [
"hide cell",
Expand Down Expand Up @@ -67,7 +67,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 35,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -333,7 +333,7 @@
"16 Monitor 2 5000 presented "
]
},
"execution_count": 15,
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -369,7 +369,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 36,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -484,7 +484,7 @@
"Trantow-Barrows 15000.0 1.333333"
]
},
"execution_count": 16,
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -502,7 +502,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 37,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -579,7 +579,7 @@
" Wendy Yule 44250.000000 3.000000"
]
},
"execution_count": 17,
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -597,7 +597,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 38,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -736,7 +736,7 @@
" Wendy Yule 3.0 2.0 NaN "
]
},
"execution_count": 18,
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -765,7 +765,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 39,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -835,7 +835,7 @@
" Wendy Yule 44250.000000"
]
},
"execution_count": 19,
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -857,17 +857,9 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 40,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/4n/v40br47s46ggrjm9bdm64lwh0000gn/T/ipykernel_34035/1265594602.py:1: FutureWarning: The provided callable <function mean at 0x7fedb7434dc0> is currently using DataFrameGroupBy.mean. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string \"mean\" instead.\n",
" pd.pivot_table(sales_df, index=[\"Manager\",\"Rep\"], values=[\"Price\"], aggfunc=[np.mean, len])\n"
]
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -953,13 +945,13 @@
" Wendy Yule 44250.000000 4"
]
},
"execution_count": 20,
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.pivot_table(sales_df, index=[\"Manager\",\"Rep\"], values=[\"Price\"], aggfunc=[np.mean, len])"
"pd.pivot_table(sales_df, index=[\"Manager\",\"Rep\"], values=[\"Price\"], aggfunc=[\"mean\", len])"
]
},
{
Expand All @@ -973,7 +965,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 41,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1185,7 +1177,7 @@
"All 1.764706 "
]
},
"execution_count": 21,
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1207,7 +1199,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 42,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1401,7 +1393,7 @@
" won 1 0 0 "
]
},
"execution_count": 22,
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -1429,7 +1421,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 43,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1562,7 +1554,7 @@
" won 0 0 0 "
]
},
"execution_count": 23,
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1580,7 +1572,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 44,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1714,7 +1706,7 @@
" won 1 0 0 "
]
},
"execution_count": 24,
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1734,7 +1726,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 45,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1801,7 +1793,7 @@
"2 3 John 88 79 90"
]
},
"execution_count": 25,
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1820,7 +1812,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 46,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1931,7 +1923,7 @@
"8 3 John History 90"
]
},
"execution_count": 26,
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
1 change: 1 addition & 0 deletions docs/_sources/ch-pandas/dataframe-merge-concat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"\n",
"```{figure} ../img/ch-pandas/merge.svg\n",
"---\n",
"width: 500px\n",
"name: merge-img\n",
"---\n",
"对两个 DataFrame 进行 merge 操作\n",
Expand Down
Loading

0 comments on commit 43bfae8

Please sign in to comment.