I have some data like this:
critical_values adf pvalue alpha decision
1% -3.465620 3.145186 1.0 0.01 accept H0 (non-stationary)
5% -2.877040 3.145186 1.0 0.05 accept H0 (non-stationary)
10% -2.575032 3.145186 1.0 0.10 accept H0 (non-stationary)
I want to style the column decision 'darkorange' if df.pvalue < df.alpha and 'lightgreen' otherwise.
I like to highlight only the column DECISION.
How to do that?
I have tried this so far:
import pandas as pd
df1 = pd.read_clipboard(sep=r'\s\s+')
df1.style.apply(lambda x: ['background: lightgreen' if (x.pvalue < x.alpha)
else 'background: darkorange' for i in x],
axis=1)
# This highlights all rows
This fails:
df1.style.apply(lambda x: ['background: lightgreen' if (x.pvalue < x.alpha)
else 'background: darkorange' for i in x],
axis=1,
subset=['decision'])
How to highlight only the decision column?