0

Very frustrating i would like to apply bold to my last column in my df after a df.to_string() Unfortunately i can't do it as i have this error : 'Styler' object has no attribute 'to_string'

Any ideas ?

def highlight_max(x):
    return ['font-weight: bold' if v == x.loc['Column_Total'] else ''
                for v in x]
dfs.style.apply(highlight_max)

decimals = 1
df1['Daily'] = df1['Daily'].apply(lambda x: round(x, decimals))
df1['Daily'] = df1['Daily'].apply(lambda x: "£{0:,.0f}".format((x)))
df1['Trade Date'] = pd.to_datetime(df1['Trade Date'])

df1['Trade Date'] = df1['Trade Date'].dt.strftime('%m/%d/%Y') 

df1 = df1.style.apply(highlight_max)
print(df1.to_string(columns=['Port','Date','Daily'], index=False))

0 Answers0