Skip to content

Commit

Permalink
Split filters
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Apr 11, 2024
1 parent 0bb7759 commit 78f0619
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
3 changes: 2 additions & 1 deletion queries/pandas/q3.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def query() -> pd.DataFrame:
jn1 = fcustomer.merge(orders_ds, left_on="c_custkey", right_on="o_custkey")
jn2 = jn1.merge(line_item_ds, left_on="o_orderkey", right_on="l_orderkey")

jn2 = jn2[(jn2["o_orderdate"] < var2) & (jn2["l_shipdate"] > var2)]
jn2 = jn2[jn2["o_orderdate"] < var2]
jn2 = jn2[jn2["l_shipdate"] > var2]
jn2["revenue"] = jn2.l_extendedprice * (1 - jn2.l_discount)

gb = jn2.groupby(
Expand Down
7 changes: 2 additions & 5 deletions queries/pandas/q4.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ def query() -> pd.DataFrame:

jn = line_item_ds.merge(orders_ds, left_on="l_orderkey", right_on="o_orderkey")

jn = jn[
(jn["o_orderdate"] < var2)
& (jn["o_orderdate"] >= var1)
& (jn["l_commitdate"] < jn["l_receiptdate"])
]
jn = jn[(jn["o_orderdate"] >= var1) & (jn["o_orderdate"] < var2)]
jn = jn[jn["l_commitdate"] < jn["l_receiptdate"]]

jn = jn.drop_duplicates(subset=["o_orderpriority", "l_orderkey"])

Expand Down
7 changes: 2 additions & 5 deletions queries/pandas/q5.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ def query() -> pd.DataFrame:
right_on=["s_suppkey", "s_nationkey"],
)

jn5 = jn5[
(jn5["r_name"] == var1)
& (jn5["o_orderdate"] >= var2)
& (jn5["o_orderdate"] < var3)
]
jn5 = jn5[jn5["r_name"] == var1]
jn5 = jn5[(jn5["o_orderdate"] >= var2) & (jn5["o_orderdate"] < var3)]
jn5["revenue"] = jn5.l_extendedprice * (1.0 - jn5.l_discount)

gb = jn5.groupby("n_name", as_index=False)["revenue"].sum()
Expand Down
11 changes: 5 additions & 6 deletions queries/pandas/q6.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ def query() -> pd.DataFrame:
var5 = 24

flineitem = line_item_ds[
(line_item_ds["l_shipdate"] >= var1)
& (line_item_ds["l_shipdate"] < var2)
& (line_item_ds["l_discount"] >= var3)
& (line_item_ds["l_discount"] <= var4)
& (line_item_ds["l_quantity"] < var5)
(line_item_ds["l_shipdate"] >= var1) & (line_item_ds["l_shipdate"] < var2)
]

flineitem = line_item_ds[
(line_item_ds["l_discount"] >= var3) & (line_item_ds["l_discount"] <= var4)
]
flineitem = line_item_ds[line_item_ds["l_quantity"] < var5]
result_value = (flineitem["l_extendedprice"] * flineitem["l_discount"]).sum()
result_df = pd.DataFrame({"revenue": [result_value]})

Expand Down

0 comments on commit 78f0619

Please sign in to comment.