ArcticDB icon indicating copy to clipboard operation
ArcticDB copied to clipboard

Fix resampling denormalization with multi-index

Open alexowens90 opened this issue 5 months ago • 0 comments

Minimal repro:

def test_resample_multiindex(lmdb_version_store_v1):
    lib = lmdb_version_store_v1
    sym = "test_resample_multiindex"
    df = pd.DataFrame(
        data={
            "a": [2, 3],
            "b": [4, 5],
        },
        index=pd.MultiIndex.from_arrays([[pd.Timestamp("2024-01-01"), pd.Timestamp("2024-01-02")], [0, 1]], names=["datetime", "sequence number"])
    )
    df.resample("D").agg({"a sum": ("a", "sum"), "b mean": ("b", "mean")})
    lib.write(sym, df)
    q = QueryBuilder()
    q = q.resample("D").agg({"a sum": ("a", "sum"), "b mean": ("b", "mean")})
    received_df = lib.read(sym, query_builder=q).data
    print(f"\n{received_df}")
# prints
                a sum
datetime             
2024-01-01 4.0      2
2024-01-02 5.0      3

i.e. the b mean column is in the place of the second-level of the index, and has lost its name

alexowens90 avatar Sep 12 '24 09:09 alexowens90