Exemplo n.º 1
0
 def test_period_count_starts_at_full_hour(self):
     # a start offset of 15 minutes is ignored when number of periods is calculated
     start = pd.Timestamp(2018, 1, 1, 0, 15)
     end = pd.Timestamp(2018, 1, 2, 0)
     series = full_hour_series(start, end, "15min")
     assert len(series) == 24 * 4
     assert series[0] == start
     assert series[-1] == end
Exemplo n.º 2
0
def _group_without_missing_data(group):
    source = group.iloc[0]
    source_zero_mw = pd.DataFrame([source])
    source_zero_mw.at[source_zero_mw.index[0], "gen_MW"] = 0
    # in case first 15 minutes are missing: make sure series starts at 15 minutes past
    start = source["timestamp"].replace(minute=15)
    end = group.iloc[-1].timestamp
    series = full_hour_series(start, end, "15min")

    def filler(t):
        filler = source_zero_mw.copy()
        filler.at[filler.index[0], "timestamp"] = t
        return filler

    def df_for_timestamp(t):
        df = group[group["timestamp"] == t]
        return df if len(df) > 0 else filler(t)

    return pd.concat([df_for_timestamp(t) for t in series], ignore_index=True)
Exemplo n.º 3
0
 def test_two_hour_series(self):
     start = pd.Timestamp(2018, 1, 1, 0)
     end = pd.Timestamp(2018, 1, 1, 2)
     series = full_hour_series(start, end, "15min")
     assert len(series) == 8
Exemplo n.º 4
0
 def test_zero_hour_series(self):
     start = pd.Timestamp(2018, 1, 1, 0)
     end = pd.Timestamp(2018, 1, 1, 0, 0)
     series = full_hour_series(start, end, "15min", min_hours=0)
     assert len(series) == 0