I'm trying to add a new column after dataframe gets df.style. However, I got an error message:
'Styler' object does not support item assignment
Below is my code:
import pandas as pd
df = pd.DataFrame([[10,3,1], [3,7,2], [2,4,4]], columns=list("ABC"))
subsets = pd.IndexSlice[:, 'A']
df2 = df.style.applymap(lambda x: 'background-color: yellow', subset = subsets)
df2['sum'] = None
Below is what I want to achieve:

How can I convert df2 to a real dataframe that I can edit? Thank you!