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

Support writing and reading back index #33

Open
j-bennet opened this issue Jul 6, 2023 · 0 comments
Open

Support writing and reading back index #33

j-bennet opened this issue Jul 6, 2023 · 0 comments

Comments

@j-bennet
Copy link
Collaborator

j-bennet commented Jul 6, 2023

Implement writing and reading back Dask dataframe index.

Right now, after reading back, index will become just another column:

from dask.datasets import timeseries
from dask_deltatable import read_delta_table
from dask_deltatable.write import to_deltalake


if __name__ == "__main__":
    ddf = timeseries("2023-07-10", "2023-07-12", freq="1H")
    print(f"\nOriginal:\n{ddf.head()}")
    ddf.index = ddf.index.astype("datetime64[us]")
    to_deltalake("t2_data", ddf).compute()
    ddf2 = read_delta_table("t2_data")
    print(f"\nRead back:\n{ddf2.head()}")

Output:

Original:
                         name    id         x         y
timestamp
2023-07-10 00:00:00  Patricia   989  0.748295  0.513837
2023-07-10 01:00:00     Jerry   993  0.487847 -0.493534
2023-07-10 02:00:00    Victor  1035  0.851038 -0.941464
2023-07-10 03:00:00     Sarah   966  0.878928 -0.087768
2023-07-10 04:00:00     Quinn   983  0.712967 -0.977796

Read back:
       name    id         x         y           timestamp
0  Patricia   989  0.748295  0.513837 2023-07-10 00:00:00
1     Jerry   993  0.487847 -0.493534 2023-07-10 01:00:00
2    Victor  1035  0.851038 -0.941464 2023-07-10 02:00:00
3     Sarah   966  0.878928 -0.087768 2023-07-10 03:00:00
4     Quinn   983  0.712967 -0.977796 2023-07-10 04:00:00

Original PR: #29.

@j-bennet j-bennet mentioned this issue Jul 6, 2023
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

1 participant