Skip to content

Commit

Permalink
Adds nbstrip to pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BielStela committed Sep 11, 2024
1 parent ac2d6c0 commit d1bed9b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ repos:
- id: ruff-format
types_or: [ python, pyi, jupyter ]

# check for private keys and passwords!
- repo: https://github.com/gitleaks/gitleaks
rev: v8.17.0
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: gitleaks-docker
- id: nbstripout
36 changes: 17 additions & 19 deletions science/notebooks/check_combine_results.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e84373c7-a5e7-47c8-95a3-d2db7ade2e29",
"id": "0",
"metadata": {},
"outputs": [],
"source": [
"import polars as pl\n",
"import polars.selectors as cs"
"import polars as pl"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "750642ad-f9fc-434e-86f8-783cc41d533c",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,16 +24,16 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d5012a5d-ea51-4b01-8ccf-055db2feb3ec",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"schema = {\"cell\":pl.UInt64, \"b\":pl.Float32, \"c\":pl.String}\n",
"schema = {\"cell\": pl.UInt64, \"b\": pl.Float32, \"c\": pl.String}\n",
"df = pl.DataFrame(schema=schema)\n",
"\n",
"join1 = pl.DataFrame({\"cell\": [1,2,3], \"b\": [9., 9., 9.]}, schema_overrides=schema)\n",
"join2 = pl.DataFrame({\"cell\": [1,2,3], \"c\": [\"a\", \"b\", \"c\"]}, schema_overrides=schema)\n",
"join3 = pl.DataFrame({\"cell\": [4,5,6], \"c\": [\"a\", \"b\", \"c\"]}, schema_overrides=schema)\n",
"join1 = pl.DataFrame({\"cell\": [1, 2, 3], \"b\": [9.0, 9.0, 9.0]}, schema_overrides=schema)\n",
"join2 = pl.DataFrame({\"cell\": [1, 2, 3], \"c\": [\"a\", \"b\", \"c\"]}, schema_overrides=schema)\n",
"join3 = pl.DataFrame({\"cell\": [4, 5, 6], \"c\": [\"a\", \"b\", \"c\"]}, schema_overrides=schema)\n",
"\n",
"tojoin = [join1, join2, join3]\n",
"\n",
Expand All @@ -46,24 +45,23 @@
{
"cell_type": "code",
"execution_count": null,
"id": "af677cc8-34c5-4259-84c2-1d90a5bf3040",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"import polars as pl\n",
"\n",
"# Define the initial DataFrame\n",
"df = pl.DataFrame({\n",
" \"cell\": [1, 2, 3, 1, 2, 3, 4, 5, 6],\n",
" \"b\": [9.0, 9.0, 9.0, None, None, None, None, None, None],\n",
" \"c\": [None, None, None, \"a\", \"b\", \"c\", \"a\", \"b\", \"c\"]\n",
"})\n",
"df = pl.DataFrame(\n",
" {\n",
" \"cell\": [1, 2, 3, 1, 2, 3, 4, 5, 6],\n",
" \"b\": [9.0, 9.0, 9.0, None, None, None, None, None, None],\n",
" \"c\": [None, None, None, \"a\", \"b\", \"c\", \"a\", \"b\", \"c\"],\n",
" }\n",
")\n",
"\n",
"# Perform the group by and aggregation\n",
"agg_df = df.groupby(\"cell\").agg([\n",
" pl.col(\"b\").max().alias(\"b\"),\n",
" pl.col(\"c\").max().alias(\"c\")\n",
"])\n",
"agg_df = df.groupby(\"cell\").agg([pl.col(\"b\").max().alias(\"b\"), pl.col(\"c\").max().alias(\"c\")])\n",
"\n",
"# Sort the resulting DataFrame by the 'cell' column\n",
"result_df = agg_df.sort(\"cell\")\n",
Expand Down

0 comments on commit d1bed9b

Please sign in to comment.