Skip to content
Advertisement

Pandas: How to multiply a index with value in a multi-index series?

I have a series as below,

JavaScript

I wanted to do something below,

JavaScript

How can I do this in a performant way?

Advertisement

Answer

Combine Series.mul with Index.get_level_values:

JavaScript

So, you can feed that to pd.cut, of course:

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