I am coding a school project rn, where I have to analyse stocks and predict them. So now my problem is the code is finished, but I want to add colours in my Excel file.
I am using the following libraries:
- requests
- bs4
- pandas
- datetime
So I looked up the whole Internet and found nothing helpful. This is my code where the Excel file is written:
JavaScript
x
20
20
1
def write_xlsx():
2
help = []
3
for i in range(len(new_price)):
4
list = []
5
list.append(new_price[i])
6
list.append(price_dif[i])
7
list.append(high[i])
8
list.append(low[i])
9
list.append(keepsell[i])
10
help.append(list)
11
list = [datetime.now(), None, None, None, None]
12
help.append(list)
13
df1 = pd.DataFrame(help, index=[get_names()], columns=['Price (€)', 'Difference (€)', 'High (€)', 'Low (€)', 'Prediction'])
14
try:
15
df1.to_excel("Stock.xlsx", sheet_name='Stonks')
16
except:
17
print("Please close the Exel Document within 15 seconds!")
18
time.sleep(15)
19
df1.to_excel("Stock.xlsx", sheet_name='Stonks')
20
I want to color my Price Differences or the High|Low column. Can you please help me how to color the Excel file.
If you need more code let me know.
Advertisement
Answer
See these posts in the Stack Overflow:
Reference-1: Coloring Cells in Pandas
Reference-2: Easiest way to create a color gradient on excel using python/pandas?