File size: 1,170 Bytes
2eae90c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import datetime
import modin.pandas as pd
from modin_queries import utils
Q_NUM = 6
def q():
date1 = datetime.datetime.strptime("1994-01-01", "%Y-%m-%d")
date2 = datetime.datetime.strptime("1995-01-01", "%Y-%m-%d")
var3 = 24
line_item_ds = utils.get_line_item_ds
# first call one time to cache in case we don't include the IO times
line_item_ds()
def query():
nonlocal line_item_ds
line_item_ds = line_item_ds()
lineitem_filtered = line_item_ds.loc[
:, ["l_quantity", "l_extendedprice", "l_discount", "l_shipdate"]
]
sel = (
(lineitem_filtered.l_shipdate >= date1)
& (lineitem_filtered.l_shipdate < date2)
& (lineitem_filtered.l_discount >= 0.05)
& (lineitem_filtered.l_discount <= 0.07)
& (lineitem_filtered.l_quantity < var3)
)
flineitem = lineitem_filtered[sel]
result_value = (flineitem.l_extendedprice * flineitem.l_discount).sum()
result_df = pd.DataFrame({"revenue": [result_value]})
return result_df
utils.run_query(Q_NUM, query)
if __name__ == "__main__":
q()
|