How to rename the index of a Dask Dataframe

This does not seem like an efficient way to do it, so I wouldn't be surprised if there is something more direct.

d.index.name starts off as 'foo';

def f(df, name):
    df.index.name = name
    return df

d.map_partitions(f, 'pow')

The output now has index name of 'pow'. If this is done with the threaded scheduler, I think you also change the index name of d in-place (in which case you don't really need the output of map_partitions).


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!