0

I have made a StyleFrame from some excel data. I want to update this StyleFrame values (for eg. I want to change the value in the cell corresponding to A1 to 5). For eg, I have the following code where sf is the styleframe object:

sf[0] = 5

This code makes the entire column after the styleframe object to 5. But I want to update the values in the styleframe. Is there anyway to do this?

1 Answers1

1

Since StyleFrame wraps the values of every cell in Container which has Styler and value to change cells value you need to do something like this

sf.loc[0, 'A'].value = 3   # change the value in cell 'A1' to 3

But

The purpose of StyleFrame is to add layer of styling to DataFrame. It is recommended to first deal with your data using DataFrame and only when your data is set, wrap it with StyleFrame and style it as you wish.

import pandas as pd
from StyleFrame import StyleFrame
df = pd.DataFrame(data={'A': [1, 2, 3], 'B': [5, 6, 7]}, columns=['A', 'B'])
df.loc[0, 'A'] = 5  # change the value in cell 'A1' to 5
sf = StyleFrame(df)
# Do the styling here...
AsafSH
  • 675
  • 6
  • 10