Skip to content
Advertisement

quickest way to swap index with values

consider the pd.Series s

JavaScript

What is the quickest way to swap index and values and get the following

JavaScript

Advertisement

Answer

One posible solution is swap keys and values by:

JavaScript

Another the fastest:

JavaScript

Timings:

JavaScript

If length of Series is 1M:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement