Skip to content
Advertisement

Accessing and overwriting Multiindex df data

I’m trying to multiply all the values of the following multiindex df for which the first multiindex equals Property_2 with a scalar:

JavaScript

I’ve tried various ways:

JavaScript

but I am getting back nan’s in the relevant places.

Advertisement

Answer

That’s because the indices don’t match. One way to get around the issue is to assign the underlying numpy array:

JavaScript

or you could use mask:

JavaScript

Output:

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