Last active
January 19, 2023 18:22
-
-
Save skrawcz/7afd48b0e4c8a0c3c391df396d674d3d to your computer and use it in GitHub Desktop.
Constant passing in Hamilton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def total_distance_travelled_by_train( ... ) -> pd.Series: | |
return # placeholder -- fill with actual logic, etc. | |
def distance_travelled_till_intermediate_station( ... ) -> pd.Series: | |
return # placeholder -- fill with actual logic, etc. | |
def journey_distance(total_distance_travelled_by_train: pd.Series, distance_travelled_till_intermediate_station: pd.Series) -> pd.Series: | |
return total_distance_travelled_by_train - distance_travelled_till_intermediate_station | |
def normalized_journey_distance(journey_distance: pd.Series, average_distance_travelled: float) -> pd.Series: | |
return journey_distance / average_distance_travelled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hamilton import driver | |
import indicators | |
# this constant can from somewhere else and be passed into the driver as "config", or as part of the execute() call (like I have below). | |
average_distance_travelled = 123.43 | |
dr = driver.Driver({}, indicators) | |
df = dr.execute(['normalized_journey_distance'], inputs={ | |
'average_distance_travelled': average_distance_travelled | |
}) | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment