Exemple #1
0
def test_make_recurrent_no_partitioning2():
    ORDER_BY = "times"
    N_RECURRENT_SAMPLES = 5

    df = sample_data1()
    arr, y = make_recurrent(df, N_RECURRENT_SAMPLES, ORDER_BY, verbose=True, price_column="val1", time_threshold=86400)
    check_results(arr, df, N_RECURRENT_SAMPLES)
Exemple #2
0
def test_gdc3():
    df = sample_data1()
    d = get_date_component(df["times"], "year")

    assert len(d) == df.shape[0]
    unique_years = np.sort(np.unique(d))
    assert len(unique_years) == 1
    assert unique_years[0] == "2020"
Exemple #3
0
def test_make_recurrent_partitioning3():
    ORDER_BY = "times"
    PARTITION_BY = "month"
    N_RECURRENT_SAMPLES = 5

    df = sample_data1()
    df[PARTITION_BY] = pd.to_datetime(df["times"]).dt.to_period("M")
    arr, y = make_recurrent(df, N_RECURRENT_SAMPLES, ORDER_BY, PARTITION_BY, verbose=True, price_column="val1", time_threshold=86400)
    check_results(arr, df, N_RECURRENT_SAMPLES, PARTITION_BY)
Exemple #4
0
def test_gdc1():
    df = sample_data1()
    d = get_date_component(df["times"], "month")

    assert len(d) == df.shape[0]
    unique_months = np.sort(np.unique(d))
    assert len(unique_months) == 2
    assert unique_months[0] == "2020-11"
    assert unique_months[1] == "2020-12"
Exemple #5
0
def test_gdc2():
    df = sample_data1()
    d = get_date_component(df["times"], "day")

    assert len(d) == df.shape[0]
    unique_days = np.sort(np.unique(d))
    assert len(unique_days) == 10
    assert unique_days[0] == "2020-11-01"
    assert unique_days[1] == "2020-11-02"
Exemple #6
0
def main():
    df = sample_data1()
    arr = make_recurrent(df,
                         3,
                         "times",
                         drop_order_by=False,
                         drop_partition_by=False)
    print(df)
    print("***********************************************")
    print(arr)
Exemple #7
0
def main():
    df = sample_data1()
    df["month"] = pd.to_datetime(df["times"]).dt.to_period("M")
    arr = make_recurrent(
        df,
        3,
        "times",
        partition_by="month",
        drop_order_by=False,
        drop_partition_by=False,
    )
    print(df)
    print("***********************************************")
    print(arr)
    print(f"Output shape is {arr.shape}")