我正在使用pycharm。我想根据该值更改单元格的颜色。我正在使用这段代码,但是这是一个固定的颜色,它给我的输出如图所示
import plotly.graph_objects as go
from plotly.colors import n_colors
import numpy as np
import pandas as pd
# np.random.seed(1)
df = pd.read_csv("IPLData.csv")
df = df.astype({"Matches": int, "Inns": int})
#
colors = n_colors(
"rgb(255, 200, 200)", "rgb(200, 0, 0)", 14, colortype="rgb"
)
a = df["Matches"]
b = df["Inns"]
c = df["Runs"]
# b = np.random.randint(low=0, high=9, size=10)
# c = np.random.randint(low=0, high=9, size=10)
fig = go.Figure(
data=[
go.Table(
header=dict(
values=list(df.columns),
line_color="white",
fill_color="white",
align="left",
),
cells=dict(
values=[df.Matches, df.Inns, df.Runs],
fill_color="lavender",
align="left",
),
)
]
)
fig.show()
期望输出
目前没有回答
相关问题 更多 >
编程相关推荐