How to rename the index of a Dask Dataframe

Viewed 2565

How would I go about renaming the index on a dask dataframe? I tried it like so

df.index.name = 'foo'

but rechecking df.index.name shows it still being whatever it was previously.

2 Answers

A bit late, but the following functions:

    import dask.dataframe as dd
    import pandas as pd
    df = pd.DataFrame().assign(s=[1, 2], o=[3, 4], p=[5, 6]).set_index("si")
    ddf = dd.from_pandas(df, npartitions=2)
    ddf.index = ddf.index.rename("si2")

I hope this can help someone else out!

Related