Seth Stokes
11/08/2024, 10:14 PM@mutate and @inject work together?
def _to_int(srs: pd.Series) -> pd.Series:
return srs.str.extract("(\d+)", expand=False).fillna(0).astype(int)
@mutate(buy_qty, sell_qty, _to_int)
@inject(buy_qty=source("Bought Quantity"), sell_qty=source("Sold Quantity"))
def QUANTITY(buy_qty: pd.Series, sell_qty: pd.Series) -> pd.Series:
"""TODO - ...
raw data:
| Index | Bought Quantity | Sold Quantity |
|:-----:|:---------------:|:-------------:|
| 0 | | 5 |
| 1 | 2 | |
| 2 | | 6 |
| 3 | 9 | |
| 4 | 6 | |
"""
return buy_qty.fillna(0) + sell_qty.fillna(0)Stefan Krawczyk
11/08/2024, 10:23 PMStefan Krawczyk
11/08/2024, 10:28 PMStefan Krawczyk
11/08/2024, 10:29 PMThierry Jean
11/08/2024, 10:59 PMsource() and @inject in order to rename columns. This way "Bought Quantity" (the raw column name) is available node name.
For the above pattern to work, you would just need a renaming step to have Bought Quantity and buy_qty be available namesSeth Stokes
11/08/2024, 11:10 PM