python - 使用 Pandas 库的 Python Excel 样式
问题描述
我正在编写一个学校项目 rn,我必须分析股票并预测它们。所以现在我的问题是代码已经完成,但我想在我的 Excel 文件中添加颜色。
我正在使用以下库:
- 要求
- BS4
- 熊猫
- 约会时间
所以我查遍了整个互联网,发现没有任何帮助。这是我编写 Excel 文件的代码:
def write_xlsx():
help = []
for i in range(len(new_price)):
list = []
list.append(new_price[i])
list.append(price_dif[i])
list.append(high[i])
list.append(low[i])
list.append(keepsell[i])
help.append(list)
list = [datetime.now(), None, None, None, None]
help.append(list)
df1 = pd.DataFrame(help, index=[get_names()], columns=['Price (€)', 'Difference (€)', 'High (€)', 'Low (€)', 'Prediction'])
try:
df1.to_excel("Stock.xlsx", sheet_name='Stonks')
except:
print("Please close the Exel Document within 15 seconds!")
time.sleep(15)
df1.to_excel("Stock.xlsx", sheet_name='Stonks')
我想为我的价格差异或高|低列着色。你能帮我如何为Excel文件着色吗?
如果您需要更多代码,请告诉我。
解决方案
推荐阅读
- ffmpeg - ffmpeg:VLC 不会打开 ffmpeg 生成的 .sdp 文件
- c - 添加 avfilter 后编译 FFMPEG/libav 代码时出错
- docker - Docker Swarm 约束共享主机
- computer-vision - 通过单相机进行室内定位(真实世界坐标)
- javascript - 将 URL 参数从 React 发送到 Node JS API
- python-3.x - Python:查找和打印字符串,每行多个实例
- amazon-web-services - AWS Amplify:如何为基于电子邮件的身份验证映射社交提供商属性?
- selenium - 使用 Selenium 循环浏览房屋列表
- reactjs - 反应路由器 this.props.history.push ,推送位置但不渲染组件
- python - 减少python中y轴点之间的空间