Skip to content

Commit

Permalink
update a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 27, 2024
1 parent 4e2a1e0 commit 304ab35
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion tpch/notebooks/gpu/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"outputs": [],
"source": [
"!pip install -U narwhals>=0.7.1"
"!pip install -U narwhals>=0.7.2"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion tpch/notebooks/q1/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"source": [
"!pip install -U pandas polars pyarrow narwhals>=0.7.1"
"!pip install -U polars pyarrow narwhals>=0.7.2 && pip uninstall pandas -y && pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas"
]
},
{
Expand Down
10 changes: 6 additions & 4 deletions tpch/notebooks/q2/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"source": [
"!pip install -U pandas polars pyarrow narwhals>=0.7.1"
"!pip install -U polars pyarrow narwhals>=0.7.2 && pip uninstall pandas -y && pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas"
]
},
{
Expand Down Expand Up @@ -126,9 +126,11 @@
" .join(supplier_ds, left_on=\"ps_suppkey\", right_on=\"s_suppkey\")\n",
" .join(nation_ds, left_on=\"s_nationkey\", right_on=\"n_nationkey\")\n",
" .join(region_ds, left_on=\"n_regionkey\", right_on=\"r_regionkey\")\n",
" .filter(nw.col(\"p_size\") == var_1)\n",
" .filter(nw.col(\"p_type\").str.ends_with(var_2))\n",
" .filter(nw.col(\"r_name\") == var_3)\n",
" .filter(\n",
" nw.col(\"p_size\") == var_1,\n",
" nw.col(\"p_type\").str.ends_with(var_2),\n",
" nw.col(\"r_name\") == var_3,\n",
" )\n",
" )\n",
"\n",
" final_cols = [\n",
Expand Down
9 changes: 5 additions & 4 deletions tpch/notebooks/q3/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"source": [
"!pip install -U pandas polars pyarrow narwhals>=0.7.1"
"!pip install -U polars pyarrow narwhals>=0.7.2 && pip uninstall pandas -y && pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas"
]
},
{
Expand Down Expand Up @@ -120,9 +120,10 @@
" customer_ds.filter(nw.col(\"c_mktsegment\") == var_3)\n",
" .join(orders_ds, left_on=\"c_custkey\", right_on=\"o_custkey\")\n",
" .join(line_item_ds, left_on=\"o_orderkey\", right_on=\"l_orderkey\")\n",
" .filter(nw.col(\"o_orderdate\") < var_2)\n",
" .filter(nw.col(\"l_shipdate\") > var_1)\n",
" .with_columns(\n",
" .filter(\n",
" nw.col(\"o_orderdate\") < var_2,\n",
" nw.col(\"l_shipdate\") > var_1,\n",
" ).with_columns(\n",
" (nw.col(\"l_extendedprice\") * (1 - nw.col(\"l_discount\"))).alias(\"revenue\")\n",
" )\n",
" .group_by([\"o_orderkey\", \"o_orderdate\", \"o_shippriority\"])\n",
Expand Down
9 changes: 5 additions & 4 deletions tpch/notebooks/q4/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"source": [
"!pip install -U pandas polars pyarrow narwhals>=0.7.1"
"!pip install -U polars pyarrow narwhals>=0.7.2 && pip uninstall pandas -y && pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas"
]
},
{
Expand Down Expand Up @@ -116,9 +116,10 @@
"\n",
" result = (\n",
" line_item_ds.join(orders_ds, left_on=\"l_orderkey\", right_on=\"o_orderkey\")\n",
" .filter(nw.col(\"o_orderdate\").is_between(var_1, var_2, closed=\"left\"))\n",
" .filter(nw.col(\"l_commitdate\") < nw.col(\"l_receiptdate\"))\n",
" .unique(subset=[\"o_orderpriority\", \"l_orderkey\"])\n",
" .filter(\n",
" nw.col(\"o_orderdate\").is_between(var_1, var_2, closed=\"left\"),\n",
" nw.col(\"l_commitdate\") < nw.col(\"l_receiptdate\"),\n",
" ).unique(subset=[\"o_orderpriority\", \"l_orderkey\"])\n",
" .group_by(\"o_orderpriority\")\n",
" .agg(nw.len().alias(\"order_count\"))\n",
" .sort(by=\"o_orderpriority\")\n",
Expand Down
2 changes: 1 addition & 1 deletion tpch/notebooks/q5/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"source": [
"!pip install -U pandas polars pyarrow narwhals>=0.7.1"
"!pip install -U polars pyarrow narwhals>=0.7.2 && pip uninstall pandas -y && pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas"
]
},
{
Expand Down
13 changes: 6 additions & 7 deletions tpch/notebooks/q6/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"source": [
"!pip install -U pandas polars pyarrow narwhals>=0.7.1"
"!pip install -U polars pyarrow narwhals>=0.7.2 && pip uninstall pandas -y && pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas"
]
},
{
Expand Down Expand Up @@ -113,11 +113,10 @@
"\n",
" result = (\n",
" line_item_ds.filter(\n",
" nw.col(\"l_shipdate\").is_between(var_1, var_2, closed=\"left\")\n",
" )\n",
" .filter(nw.col(\"l_discount\").is_between(0.05, 0.07))\n",
" .filter(nw.col(\"l_quantity\") < var_3)\n",
" .with_columns(\n",
" nw.col(\"l_shipdate\").is_between(var_1, var_2, closed=\"left\"),\n",
" nw.col(\"l_discount\").is_between(0.05, 0.07),\n",
" nw.col(\"l_quantity\") < var_3,\n",
" ).with_columns(\n",
" (nw.col(\"l_extendedprice\") * nw.col(\"l_discount\")).alias(\"revenue\")\n",
" )\n",
" .select(nw.sum(\"revenue\"))\n",
Expand Down Expand Up @@ -446,7 +445,7 @@
"source": [
"tool = 'polars[lazy]'\n",
"fn = IO_FUNCS[tool]\n",
"timings = %timeit -o q6(fn(lineitem))\n",
"timings = %timeit -o q6(fn(lineitem)).collect()\n",
"results[tool] = timings.best"
]
},
Expand Down
8 changes: 4 additions & 4 deletions tpch/notebooks/q7/execute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"source": [
"!pip install -U pandas polars pyarrow narwhals>=0.7.1"
"!pip install -U polars pyarrow narwhals>=0.7.2 && pip uninstall pandas -y && pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas"
]
},
{
Expand Down Expand Up @@ -120,8 +120,8 @@
" n1 = nation_ds.filter(nw.col(\"n_name\") == \"FRANCE\")\n",
" n2 = nation_ds.filter(nw.col(\"n_name\") == \"GERMANY\")\n",
"\n",
" var_1 = date(1995, 1, 1)\n",
" var_2 = date(1996, 12, 31)\n",
" var_1 = datetime(1995, 1, 1)\n",
" var_2 = datetime(1996, 12, 31)\n",
"\n",
" df1 = (\n",
" customer_ds.join(n1, left_on=\"c_nationkey\", right_on=\"n_nationkey\")\n",
Expand Down Expand Up @@ -476,7 +476,7 @@
"source": [
"tool = 'polars[lazy]'\n",
"fn = IO_FUNCS[tool]\n",
"timings = %timeit -o q7(fn(nation), fn(customer), fn(lineitem), fn(orders), fn(supplier))\n",
"timings = %timeit -o q7(fn(nation), fn(customer), fn(lineitem), fn(orders), fn(supplier)).collect()\n",
"results[tool] = timings.best"
]
},
Expand Down

0 comments on commit 304ab35

Please sign in to comment.