Spaces:
Sleeping
Sleeping
Update run.py
Browse files
run.py
CHANGED
@@ -1,16 +1,58 @@
|
|
1 |
-
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
-
df = pd.DataFrame({"A" : [14, 4, 5, 4, 1],
|
5 |
-
"B" : [5, 2, 54, 3, 2],
|
6 |
-
"C" : [20, 20, 7, 3, 8],
|
7 |
-
"D" : [14, 3, 6, 2, 6],
|
8 |
-
"E" : [23, 45, 64, 32, 23]})
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
with gr.Blocks() as demo:
|
13 |
-
gr.Dataframe(
|
14 |
-
|
15 |
if __name__ == "__main__":
|
16 |
-
demo.launch()
|
|
|
1 |
+
|
2 |
+
import pandas as pd
|
3 |
import gradio as gr
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
# Sample DataFrame
|
7 |
+
data = {
|
8 |
+
"Name": [
|
9 |
+
"Alice",
|
10 |
+
"Bob",
|
11 |
+
"Charlie",
|
12 |
+
"David",
|
13 |
+
"Eva",
|
14 |
+
"Charlize",
|
15 |
+
"Barbara",
|
16 |
+
"Hans",
|
17 |
+
"Sandra",
|
18 |
+
"Erik",
|
19 |
+
],
|
20 |
+
"Age": [25, 30, 35, 40, 45, 29, 80, 95, 10, 25],
|
21 |
+
"Score": [88, 92, 87, 94, 90, 88, 92, 87, 94, 90],
|
22 |
+
"likes_cheese": [
|
23 |
+
"no",
|
24 |
+
"yes",
|
25 |
+
"no_opinion",
|
26 |
+
"yes",
|
27 |
+
"no",
|
28 |
+
"no",
|
29 |
+
"yes",
|
30 |
+
"no_opinion",
|
31 |
+
"yes",
|
32 |
+
"no",
|
33 |
+
],
|
34 |
+
}
|
35 |
+
df = pd.DataFrame(data)
|
36 |
+
|
37 |
+
# Define colors for the different values in the "likes_cheese" column
|
38 |
+
colors = {
|
39 |
+
"yes": "lightgreen",
|
40 |
+
"no": "lightcoral",
|
41 |
+
"no_opinion": "#eee",
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
def highlight_row(s):
|
46 |
+
color = colors[s["likes_cheese"]]
|
47 |
+
# we set the text color to dark gray here so that it is readable
|
48 |
+
return ["color: #333; background-color: %s" % color for _ in s]
|
49 |
+
|
50 |
+
|
51 |
+
styler = df.style.apply(highlight_row, axis="columns")
|
52 |
+
|
53 |
|
54 |
with gr.Blocks() as demo:
|
55 |
+
gr.Dataframe(styler)
|
56 |
+
|
57 |
if __name__ == "__main__":
|
58 |
+
demo.launch()
|