File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed
feature_engine/timeseries/forecasting Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,28 @@ class ExpandingWindowFeatures(BaseForecastTransformer):
117117 pandas.expanding
118118 pandas.aggregate
119119 pandas.shift
120+
121+ Examples
122+ --------
123+
124+ >>> import pandas as pd
125+ >>> from feature_engine.timeseries.forecasting import ExpandingWindowFeatures
126+ >>> X = pd.DataFrame(dict(date = ["2022-09-18",
127+ >>> "2022-09-19",
128+ >>> "2022-09-20",
129+ >>> "2022-09-21",
130+ >>> "2022-09-22"],
131+ >>> x1 = [1,2,3,4,5],
132+ >>> x2 = [6,7,8,9,10]
133+ >>> ))
134+ >>> ewf = ExpandingWindowFeatures()
135+ >>> ewf.fit_transform(X)
136+ date x1 x2 x1_expanding_mean x2_expanding_mean
137+ 0 2022-09-18 1 6 NaN NaN
138+ 1 2022-09-19 2 7 1.0 6.0
139+ 2 2022-09-20 3 8 1.5 6.5
140+ 3 2022-09-21 4 9 2.0 7.0
141+ 4 2022-09-22 5 10 2.5 7.5
120142 """
121143
122144 def __init__ (
Original file line number Diff line number Diff line change @@ -95,6 +95,28 @@ class LagFeatures(BaseForecastTransformer):
9595 See Also
9696 --------
9797 pandas.shift
98+
99+ Examples
100+ --------
101+
102+ >>> import pandas as pd
103+ >>> from feature_engine.timeseries.forecasting import LagFeatures
104+ >>> X = pd.DataFrame(dict(date = ["2022-09-18",
105+ >>> "2022-09-19",
106+ >>> "2022-09-20",
107+ >>> "2022-09-21",
108+ >>> "2022-09-22"],
109+ >>> x1 = [1,2,3,4,5],
110+ >>> x2 = [6,7,8,9,10]
111+ >>> ))
112+ >>> lf = LagFeatures(periods=[1,2])
113+ >>> lf.fit_transform(X)
114+ date x1 x2 x1_lag_1 x2_lag_1 x1_lag_2 x2_lag_2
115+ 0 2022-09-18 1 6 NaN NaN NaN NaN
116+ 1 2022-09-19 2 7 1.0 6.0 NaN NaN
117+ 2 2022-09-20 3 8 2.0 7.0 1.0 6.0
118+ 3 2022-09-21 4 9 3.0 8.0 2.0 7.0
119+ 4 2022-09-22 5 10 4.0 9.0 3.0 8.0
98120 """
99121
100122 def __init__ (
Original file line number Diff line number Diff line change @@ -121,6 +121,28 @@ class WindowFeatures(BaseForecastTransformer):
121121 pandas.rolling
122122 pandas.aggregate
123123 pandas.shift
124+
125+ Examples
126+ --------
127+
128+ >>> import pandas as pd
129+ >>> from feature_engine.timeseries.forecasting import WindowFeatures
130+ >>> X = pd.DataFrame(dict(date = ["2022-09-18",
131+ >>> "2022-09-19",
132+ >>> "2022-09-20",
133+ >>> "2022-09-21",
134+ >>> "2022-09-22"],
135+ >>> x1 = [1,2,3,4,5],
136+ >>> x2 = [6,7,8,9,10]
137+ >>> ))
138+ >>> wf = WindowFeatures(window = 2)
139+ >>> wf.fit_transform(X)
140+ date x1 x2 x1_window_2_mean x2_window_2_mean
141+ 0 2022-09-18 1 6 NaN NaN
142+ 1 2022-09-19 2 7 NaN NaN
143+ 2 2022-09-20 3 8 1.5 6.5
144+ 3 2022-09-21 4 9 2.5 7.5
145+ 4 2022-09-22 5 10 3.5 8.5
124146 """
125147
126148 def __init__ (
You can’t perform that action at this time.
0 commit comments