I have a data-frame with multi-index like this:
Date Period Value \n
20130101 0 12 \n
20130101 1 13
20130102 0 13
20130102 1 14
The first level is Date and the second level is period. I would like to set the values where the period is not zero to zero, the output would be something like this:
Date Period Value
20130101 0 12
20130101 1 0
20130102 0 13
20130102 1 0
If the second level was a column as opposed to index, the solution would be easy df.Value.loc[df.Period == 0] =0
.
Is there a way to achieve this, by just using index?