python - 如何在 Streamlit 中更改熊猫数据框中行的颜色?
问题描述
如何在 Streamlit 中更改熊猫数据框中行的颜色?
我使用的是浅色背景,我想将黑色作为行颜色。
解决方案
import pandas as pd
import numpy as np
# Seeding random data from numpy
np.random.seed(24)
# Making the DatFrame
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4),
columns=list('BCDE'))], axis=1)
# DataFrame without any styling
print("Original DataFrame:\n")
print(df)
print("\nModified Stlying DataFrame:")
df.style.set_properties(**{'background-color': 'black',
'color': 'green'})
With this code, you can set the background color of the data frame as black and the text color: green
推荐阅读
- angular - 为什么@Output 事件在选择器名称中?
- javascript - 如何更改菜单选项卡 html 的活动颜色?
- c++ - 更新已排序向量的一项
- html - 如何在没有边界的情况下分隔孩子?
- r - 将边际总计添加到 R 中的 ggplot 热图
- jquery - .outerheight() 有问题
- html - 我需要制作一个 4 列 3 行的图片库,所有这些图片的大小都相同
- maven - 如何为 gradle 安装 sdkman
- javascript - 还有另一种在 URL http Delete 请求上添加 ID 的方法吗?
- javascript - Apollo Server gql 使用推荐