'Highlight distinct cells based on a different cell in the same row in a multiindex pivot table

I have created a pivot table where the column headers have several levels. This is a simplified version:

index = ['Person 1', 'Person 2', 'Person 3']
columns = [
    ["condition 1", "condition 1", "condition 1", "condition 2", "condition 2", "condition 2"],
    ["Mean", "SD", "n", "Mean", "SD", "n"],
]
data = [
    [100, 10, 3, 200, 12, 5],
    [500, 20, 4, 750, 6, 6],
    [1000, 30, 5, None, None, None],
]
df = pd.DataFrame(data, columns=columns)

df

Now I would like to highlight the adjacent cells next to SD if SD > 10. This is how it should look like: wanted outcome

I found this answer but couldn't make it work for multiindices.

Thanks for any help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source