Package: timeseries-feature-engineering
Time Series Feature EngineeringTime series feature generator.Installpip install timeseries_feature_engineeringHow to useAdd Date Partsdf=pd.DataFrame({'date':['2019-12-04',None,'2019-11-15','2019-10-24']})df=add_datepart(df,'date')df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>YearMonthWeekDayDayofweekDayofyearIs_month_endIs_month_startIs_quarter_endIs_quarter_startIs_year_endIs_year_startElapsed02019.012.049.04.02.0338.0FalseFalseFalseFalseFalseFalse15754176001NaNNaNNaNNaNNaNNaNFalseFalseFalseFalseFalseFalseNone22019.011.046.015.04.0319.0FalseFalseFalseFalseFalseFalse157377600032019.010.043.024.03.0297.0FalseFalseFalseFalseFalseFalse1571875200Add Moving Average FeaturesWith weighted average.Recency in an important factor in a time series. Values closer to the current date would hold more information.df=pd.DataFrame({'date':pd.date_range('2019-12-01','2019-12-10'),'sales':np.random.randint(100,500,size=10)})df=add_moving_average_features(df,'sales',windows=[3,5],weighted=True)df.head(10)<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>datesalessales_3p_MAsales_5p_MA02019-12-01155NaNNaN12019-12-02437NaNNaN22019-12-03361352.000000NaN32019-12-04356371.166667NaN42019-12-05490423.833333399.06666752019-12-06222333.666667353.13333362019-12-07197254.166667294.40000072019-12-08390297.666667316.00000082019-12-09159242.333333258.66666792019-12-10470353.000000318.133333Without weighted average.df=pd.DataFrame({'date':pd.date_range('2019-12-01','2019-12-10'),'sales':np.random.randint(100,500,size=10)})df=add_moving_average_features(df,'sales',windows=[3,5],weighted=True)df.head(10)<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>datesalessales_3p_MAsales_5p_MA02019-12-01167NaNNaN12019-12-02458NaNNaN22019-12-03260310.500000NaN32019-12-04174250.000000NaN42019-12-05392297.333333301.26666752019-12-06401360.166667338.20000062019-12-07460429.000000379.20000072019-12-08381410.666667393.73333382019-12-09349378.166667389.53333392019-12-10365362.333333379.000000Add Expanding Featuresdf=pd.DataFrame({'date':pd.date_range('2019-12-01','2019-12-10'),'sales':np.random.randint(100,500,size=10)})df=add_expanding_features(df,'sales',period=3)df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>datesalessales_3p_expanding02019-12-01178NaN12019-12-02398NaN22019-12-03399325.032019-12-04385340.042019-12-05136299.2Add Trend Featuresdf=pd.DataFrame({'date':pd.date_range('2019-12-01','2019-12-10'),'sales':np.random.randint(100,500,size=10)})df=add_trend_features(df,'sales',windows=[3,7])df.head(10)<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>datesalessales_3p_trendsales_7p_trend02019-12-012370.0000000.00000012019-12-023880.0000000.00000022019-12-033840.0000000.00000032019-12-0449887.0000000.00000042019-12-05275-37.6666670.00000052019-12-06382-0.6666670.00000062019-12-07132-122.0000000.00000072019-12-0833720.66666714.28571482019-12-0949638.00000015.42857192019-12-1021628.000000-24.000000