1
sf = sf[[col for col in sf.columns
         if col.style.fill.fgColor.rgb in ('FFFFFFFF', utils.colors.white)]]

I got an error when read the file and looping the columns

return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'columns'

I want to read the excel without loosing the style values

DeepSpace
  • 78,697
  • 11
  • 109
  • 154
Suresh K
  • 71
  • 1
  • 10

1 Answers1

2

That's a bug in StyleFrame that is caused by the fact that [col for col in sf.columns if col.style.fill.fgColor.rgb in ('FFFFFFFF', utils.colors.white)] returns an empty list (ie, the condition is False for every column).

This will be fixed in the next version.

A temporary workaround:

required_cols = [col for col in sf.columns
                 if col.style.fill.fgColor.rgb in ('FFFFFFFF', utils.colors.white)]
sf = sf[required_cols] if required_cols else StyleFrame(pd.DataFrame(columns=sf.columns))
DeepSpace
  • 78,697
  • 11
  • 109
  • 154