Run black on all the notebooks

- we use black's default settings
- some cells are NOT kept in black's format to:
  - increase readability
  - or show Python's flexibility with regard to style
This commit is contained in:
Alexander Hess 2024-07-15 12:07:47 +02:00
commit 51a5dcc8ee
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
6 changed files with 45 additions and 67 deletions

View file

@ -282,10 +282,12 @@
}
],
"source": [
"m1 = np.array([\n",
" [1, 2, 3, 4, 5],\n",
" [6, 7, 8, 9, 10],\n",
"])\n",
"m1 = np.array(\n",
" [\n",
" [1, 2, 3, 4, 5],\n",
" [6, 7, 8, 9, 10],\n",
" ]\n",
")\n",
"\n",
"m1"
]

View file

@ -1852,10 +1852,7 @@
}
],
"source": [
"df.loc[\n",
" 200300:200800,\n",
" [\"o_street\", \"o_zip\", \"o_city\", \"o_latitude\", \"o_longitude\"]\n",
"]"
"df.loc[200300:200800, [\"o_street\", \"o_zip\", \"o_city\", \"o_latitude\", \"o_longitude\"]]"
]
},
{
@ -1982,11 +1979,13 @@
"metadata": {},
"outputs": [],
"source": [
"df = df.astype({\n",
" \"pickup_at\": \"datetime64[ns]\",\n",
" \"delivery_at\": \"datetime64[ns]\",\n",
" \"cancelled\": bool,\n",
"})"
"df = df.astype(\n",
" {\n",
" \"pickup_at\": \"datetime64[ns]\",\n",
" \"delivery_at\": \"datetime64[ns]\",\n",
" \"cancelled\": bool,\n",
" }\n",
")"
]
},
{
@ -2686,7 +2685,7 @@
"source": [
"df.loc[\n",
" max_a_table,\n",
" [\"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"d_latitude\", \"d_longitude\"]\n",
" [\"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"d_latitude\", \"d_longitude\"],\n",
"].head()"
]
},
@ -2821,12 +2820,10 @@
" max_a_table\n",
" &\n",
" (\n",
" (df[\"d_latitude\"] > 44.85)\n",
" |\n",
" (df[\"d_longitude\"] < -0.59)\n",
" ) \n",
" (df[\"d_latitude\"] > 44.85) | (df[\"d_longitude\"] < -0.59)\n",
" )\n",
" ),\n",
" [\"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"d_latitude\", \"d_longitude\"]\n",
" [\"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"d_latitude\", \"d_longitude\"],\n",
"].head()"
]
},
@ -2933,12 +2930,8 @@
],
"source": [
"df.loc[\n",
" (\n",
" max_a_table\n",
" &\n",
" df[\"customer_id\"].isin([6037, 79900, 80095])\n",
" ),\n",
" [\"placed_at\", \"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"total\"]\n",
" (max_a_table & df[\"customer_id\"].isin([6037, 79900, 80095])),\n",
" [\"placed_at\", \"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"total\"],\n",
"].head()"
]
},
@ -3067,12 +3060,8 @@
],
"source": [
"df.loc[\n",
" (\n",
" max_a_table\n",
" &\n",
" ~df[\"customer_id\"].isin([6037, 79900, 80095])\n",
" ),\n",
" [\"placed_at\", \"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"total\"]\n",
" (max_a_table & ~df[\"customer_id\"].isin([6037, 79900, 80095])),\n",
" [\"placed_at\", \"customer_id\", \"d_street\", \"d_zip\", \"d_city\", \"total\"],\n",
"].head()"
]
},
@ -3166,10 +3155,7 @@
}
],
"source": [
"df.loc[\n",
" max_a_table,\n",
" \"customer_id\"\n",
"].unique()"
"df.loc[max_a_table, \"customer_id\"].unique()"
]
},
{
@ -3289,10 +3275,7 @@
}
],
"source": [
"df.loc[\n",
" max_a_table,\n",
" \"total\"\n",
"].sum() / 100"
"df.loc[max_a_table, \"total\"].sum() / 100"
]
},
{
@ -3352,10 +3335,7 @@
}
],
"source": [
"df.loc[\n",
" max_a_table,\n",
" \"total\"\n",
"].min() / 100"
"df.loc[max_a_table, \"total\"].min() / 100"
]
},
{
@ -3375,10 +3355,7 @@
}
],
"source": [
"df.loc[\n",
" max_a_table,\n",
" \"total\"\n",
"].max() / 100"
"df.loc[max_a_table, \"total\"].max() / 100"
]
},
{
@ -3438,10 +3415,7 @@
}
],
"source": [
"df.loc[\n",
" max_a_table,\n",
" \"total\"\n",
"].mean().round() / 100"
"df.loc[max_a_table, \"total\"].mean().round() / 100"
]
}
],

View file

@ -56,7 +56,7 @@
" \"orders.csv\",\n",
" index_col=\"order_id\",\n",
" dtype={\"cancelled\": bool},\n",
" parse_dates=[\"placed_at\", \"pickup_at\", \"delivery_at\"]\n",
" parse_dates=[\"placed_at\", \"pickup_at\", \"delivery_at\"],\n",
")"
]
},