Skip to content

Commit

Permalink
remove cell outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
zstumgoren committed Mar 29, 2024
1 parent 59f5323 commit 3324f5d
Showing 1 changed file with 16 additions and 190 deletions.
206 changes: 16 additions & 190 deletions content/classes_and_oop/method_chaining.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,10 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"id": "953f21c1-84a7-4fec-b14e-d21ec2593604",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['SOME SCREAMY TEXT', ' WITH A COMMA']"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"\"some text, with a comma\".upper().replace(\"TEXT\", \"SCREAMY TEXT\").split(',')"
]
Expand Down Expand Up @@ -83,67 +72,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "fc843922-655c-4662-b8fe-7505268e505a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>first</th>\n",
" <th>last</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Joe</td>\n",
" <td>Smith</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Jane</td>\n",
" <td>Smith</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Jane</td>\n",
" <td>Doe</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" first last\n",
"0 Joe Smith\n",
"1 Jane Smith\n",
"2 Jane Doe"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import pandas as pd\n",
"d = {\n",
Expand All @@ -164,61 +96,10 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "0a619dcc-6dc7-4aba-bbcb-268b3b67485b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>first</th>\n",
" <th>count_of_first_names</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Jane</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Joe</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" first count_of_first_names\n",
"0 Jane 2\n",
"1 Joe 1"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"df.groupby('first').size().rename('count_of_first_names').reset_index()"
]
Expand All @@ -237,21 +118,10 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "427067f0-5624-4a12-a65c-193bf3de1d53",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.groupby.generic.DataFrameGroupBy"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"grouped = df.groupby('first')\n",
"type(grouped)"
Expand Down Expand Up @@ -291,21 +161,10 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "ff0f4e80-c86a-48de-8ee2-d4679b7c97a9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Jane': [1, 2], 'Joe': [0]}"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"grouped.groups"
]
Expand All @@ -324,65 +183,32 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"id": "8725697e-2cd6-4e0e-86f7-5486321eccb1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.series.Series"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"sized = grouped.size()\n",
"type(sized) # Now we have a pandas Series"
]
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"id": "180bdbc7-e61a-4286-8e70-0c139be9bd8b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.series.Series"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"renamed = sized.rename('count_of_first_names')\n",
"type(renamed) # still a Series..."
]
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"id": "b484f1b0-e249-4fcb-9caa-9e72829a9466",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.frame.DataFrame"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"new_df = renamed.reset_index()\n",
"type(df) # Now back to a DataFrame"
Expand Down

0 comments on commit 3324f5d

Please sign in to comment.