Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resampling denormalization with multi-index #1830

Open
alexowens90 opened this issue Sep 12, 2024 · 0 comments
Open

Fix resampling denormalization with multi-index #1830

alexowens90 opened this issue Sep 12, 2024 · 0 comments
Assignees

Comments

@alexowens90
Copy link
Collaborator

alexowens90 commented Sep 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants