Skip to content

Commit 8ea910f

Browse files
authored
rename _ProcessedDF (#95)
1 parent 89994fd commit 8ea910f

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

nbs/processing.ipynb

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,33 +1630,24 @@
16301630
{
16311631
"cell_type": "code",
16321632
"execution_count": null,
1633-
"id": "4de12264-0bd1-4eed-935b-7b7fb1cbebc0",
1633+
"id": "62293bd2-b921-40b2-b1af-25f0b8e55006",
16341634
"metadata": {},
16351635
"outputs": [],
16361636
"source": [
1637-
"#| exporti\n",
1638-
"class _ProcessedDF(NamedTuple):\n",
1637+
"#| export\n",
1638+
"class ProcessedDF(NamedTuple):\n",
16391639
" uids: Series\n",
1640-
" times: np.ndarray\n",
1640+
" last_times: np.ndarray\n",
16411641
" data: np.ndarray\n",
16421642
" indptr: np.ndarray\n",
1643-
" sort_idxs: Optional[np.ndarray]"
1644-
]
1645-
},
1646-
{
1647-
"cell_type": "code",
1648-
"execution_count": null,
1649-
"id": "62293bd2-b921-40b2-b1af-25f0b8e55006",
1650-
"metadata": {},
1651-
"outputs": [],
1652-
"source": [
1653-
"#| export\n",
1643+
" sort_idxs: Optional[np.ndarray]\n",
1644+
"\n",
16541645
"def process_df(\n",
16551646
" df: DataFrame,\n",
16561647
" id_col: str,\n",
16571648
" time_col: str,\n",
16581649
" target_col: Optional[str],\n",
1659-
") -> _ProcessedDF:\n",
1650+
") -> ProcessedDF:\n",
16601651
" \"\"\"Extract components from dataframe\n",
16611652
" \n",
16621653
" Parameters\n",
@@ -1699,7 +1690,7 @@
16991690
" data = data[sort_idxs]\n",
17001691
" last_idxs = sort_idxs[last_idxs]\n",
17011692
" times = df[time_col].to_numpy()[last_idxs]\n",
1702-
" return _ProcessedDF(uids, times, data, indptr, sort_idxs)"
1693+
" return ProcessedDF(uids, times, data, indptr, sort_idxs)"
17031694
]
17041695
},
17051696
{

utilsforecast/_modidx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
'utilsforecast/processing.py'),
8585
'utilsforecast.processing.DataFrameProcessor.process': ( 'processing.html#dataframeprocessor.process',
8686
'utilsforecast/processing.py'),
87-
'utilsforecast.processing._ProcessedDF': ( 'processing.html#_processeddf',
88-
'utilsforecast/processing.py'),
87+
'utilsforecast.processing.ProcessedDF': ( 'processing.html#processeddf',
88+
'utilsforecast/processing.py'),
8989
'utilsforecast.processing._ensure_month_ends': ( 'processing.html#_ensure_month_ends',
9090
'utilsforecast/processing.py'),
9191
'utilsforecast.processing._multiply_pl_freq': ( 'processing.html#_multiply_pl_freq',

utilsforecast/processing.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'horizontal_concat', 'copy_if_pandas', 'join', 'drop_index_if_pandas', 'rename', 'sort', 'offset_times',
77
'offset_dates', 'time_ranges', 'repeat', 'cv_times', 'group_by', 'group_by_agg', 'is_in', 'between',
88
'fill_null', 'cast', 'value_cols_to_numpy', 'make_future_dataframe', 'anti_join', 'ensure_sorted',
9-
'process_df', 'DataFrameProcessor', 'backtest_splits', 'add_insample_levels']
9+
'ProcessedDF', 'process_df', 'DataFrameProcessor', 'backtest_splits', 'add_insample_levels']
1010

1111
# %% ../nbs/processing.ipynb 2
1212
import re
@@ -641,20 +641,20 @@ def ensure_sorted(df: DataFrame, id_col: str, time_col: str) -> DataFrame:
641641
return df
642642

643643
# %% ../nbs/processing.ipynb 75
644-
class _ProcessedDF(NamedTuple):
644+
class ProcessedDF(NamedTuple):
645645
uids: Series
646-
times: np.ndarray
646+
last_times: np.ndarray
647647
data: np.ndarray
648648
indptr: np.ndarray
649649
sort_idxs: Optional[np.ndarray]
650650

651-
# %% ../nbs/processing.ipynb 76
651+
652652
def process_df(
653653
df: DataFrame,
654654
id_col: str,
655655
time_col: str,
656656
target_col: Optional[str],
657-
) -> _ProcessedDF:
657+
) -> ProcessedDF:
658658
"""Extract components from dataframe
659659
660660
Parameters
@@ -697,9 +697,9 @@ def process_df(
697697
data = data[sort_idxs]
698698
last_idxs = sort_idxs[last_idxs]
699699
times = df[time_col].to_numpy()[last_idxs]
700-
return _ProcessedDF(uids, times, data, indptr, sort_idxs)
700+
return ProcessedDF(uids, times, data, indptr, sort_idxs)
701701

702-
# %% ../nbs/processing.ipynb 78
702+
# %% ../nbs/processing.ipynb 77
703703
class DataFrameProcessor:
704704
def __init__(
705705
self,
@@ -716,7 +716,7 @@ def process(
716716
) -> Tuple[Series, np.ndarray, np.ndarray, np.ndarray, Optional[np.ndarray]]:
717717
return process_df(df, self.id_col, self.time_col, self.target_col)
718718

719-
# %% ../nbs/processing.ipynb 83
719+
# %% ../nbs/processing.ipynb 82
720720
def _single_split(
721721
df: DataFrame,
722722
i_window: int,
@@ -781,7 +781,7 @@ def _single_split(
781781
)
782782
return cutoffs, train_mask, valid_mask
783783

784-
# %% ../nbs/processing.ipynb 84
784+
# %% ../nbs/processing.ipynb 83
785785
def backtest_splits(
786786
df: DataFrame,
787787
n_windows: int,
@@ -813,7 +813,7 @@ def backtest_splits(
813813
valid = filter_with_mask(df, valid_mask)
814814
yield cutoffs, train, valid
815815

816-
# %% ../nbs/processing.ipynb 88
816+
# %% ../nbs/processing.ipynb 87
817817
def add_insample_levels(
818818
df: DataFrame,
819819
models: List[str],

0 commit comments

Comments
 (0)