I have extracted xlsx data into pandas dataframe and used style.format to format particular columns into percentages and dollars. So now my dataframe is converted to styler object, because I need to parse this data into csv. I have to convert this object into dataframe please help.
below is the code and output:
import pandas as pd
import numpy as np
file_path = "./sample_data.xlsx"
df = pd.read_excel(file_path, sheet_name = "Channel",skiprows=10, header =
[0,1,2])
dollar_cols = ['SalesTY', 'SalesLY','InStoreTY', 'InStoreLY','eCommTY']
dollar_dict = {}
for dollar_col in dollar_cols:
formatdict[dollar_col] = "${:,.0f}"
final_df = df.style.format(formatdict)
Here final_df has the columns converted to dollars but I am unable to convert this to csv or into a data frame. It's a styler object now, I need to convert this into a data frame again. Any help is appreciated. Thanks.