-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
Description
While creating a minimal working example to illustrate a problem I run into this error:
Traceback (most recent call last):
File "C:\Users\buhtzch\Desktop\x.py", line 25, in <module>
sf.to_excel(file_path).save()
File "C:\Users\buhtzch\AppData\Roaming\Python\Python39\site-packages\styleframe\style_frame.py", line 503, in to_excel
data_df_style = self.data_df.at[index, column].style
File "C:\Users\buhtzch\AppData\Roaming\Python\Python39\site-packages\pandas\core\generic.py", line 5478, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'style'
And I don't understand the root of the problem. Maybe I did something wrong or this is a bug or edgy use case?
Version info
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]
pandas 1.3.0
openpyxl 3.0.9
StyleFrame 4.1
This is the code to reproduce.
#!/usr/bin/env python3
import os
import sys
import pathlib
import pandas
import styleframe
import styleframe.utils
print(styleframe._versions_)
df = pandas.DataFrame(
data={
'idx1': list('AABB'),
'column with long caption': [1234, 345, 33123, 2],
}
)
df = df.set_index('idx1')
print(df)
file_path = pathlib.Path.cwd() / 'test.xlsx'
default_style = styleframe.Styler(font_size=14)
sf = styleframe.StyleFrame(df, styler_obj=default_style)
sf.to_excel(file_path).save()
os.system(str(file_path))
EDIT:
The exception is not raised when I out-comment the line df = df.set_index('idx1').
Eldolfin