Hi, I am using the following versions:
- Python: 3.8.10
- StyleFrame: 4.0.0
- Pandas: 1.3.1
- Openpyxl: 3.0.7
The following code:
def _decorate_excel(df: pd.DataFrame, xl: str):
excel_writer = StyleFrame.ExcelWriter(xl)
sf = StyleFrame(df.reset_index())
for color, col_name in product(TRAFFIC_LIGHTS_COLORS, TRAFFIC_LIGHTS_COLS):
# Set the background color
style = Styler(bg_color=color.lower(), font_color=utils.colors.black)
sf.apply_style_by_indexes(indexes_to_style=sf[sf[col_name] == color],
cols_to_style=col_name,
styler_obj=style,
overwrite_default_style=False)
where color can be YELLOW, GREEN, etc. and col_name are some of the columns of my DataFrame transformed into a StyleFrame.
Though I get the following error:
File "/home/mlpoc/projects/churn-v2/vchurn/main_predict.py", line 40, in _decorate_excel
sf.apply_style_by_indexes(indexes_to_style=sf[sf[col_name] == color],
File "/home/mlpoc/miniconda3/envs/churn/lib/python3.8/site-packages/styleframe/style_frame.py", line 638, in apply_style_by_indexes
self.iloc[self.index.get_loc(index), self.columns.get_loc(col)].style = style_to_apply
File "/home/mlpoc/miniconda3/envs/churn/lib/python3.8/site-packages/pandas/core/generic.py", line 5478, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'get_loc'
Hi, I am using the following versions:
The following code:
where color can be
YELLOW,GREEN, etc. and col_name are some of the columns of my DataFrame transformed into a StyleFrame.Though I get the following error: