Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Adds documentation showing scalar creation & input
Browse files Browse the repository at this point in the history
Functions can create or take in scalars. Adding this to the
example so that people can see that more explicitly.
  • Loading branch information
skrawcz committed Dec 12, 2021
1 parent b7c696e commit 4b0a6e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/hello_world/my_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ def avg_3wk_spend(spend: pd.Series) -> pd.Series:
def spend_per_signup(spend: pd.Series, signups: pd.Series) -> pd.Series:
"""The cost per signup in relation to spend."""
return spend / signups


def single_avg(spend: pd.Series) -> float:
"""Shows function creating a scalar."""
return spend.mean()


def spend_per_signup_time_average(single_avg: float, spend_per_signup: pd.Series) -> pd.Series:
"""Shows a function that takes in a scalar."""
return single_avg * spend_per_signup
2 changes: 2 additions & 0 deletions examples/hello_world/my_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
logger = logging.getLogger(__name__)
logging.basicConfig(stream=sys.stdout)
initial_columns = { # load from actuals or wherever -- this is our initial data we use as input.
# Note: these values don't have to be all series, they could be a scalar.
'signups': pd.Series([1, 10, 50, 100, 200, 400]),
'spend': pd.Series([10, 10, 20, 40, 40, 50]),
}
Expand All @@ -21,6 +22,7 @@
'signups',
'avg_3wk_spend',
'spend_per_signup',
'spend_per_signup_time_average'
]
# let's create the dataframe!
df = dr.execute(output_columns, display_graph=True)
Expand Down

0 comments on commit 4b0a6e4

Please sign in to comment.