Kilos1 commited on
Commit
8abb89c
·
verified ·
1 Parent(s): 0ec9e77

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+
4
+ # Creating a sample dataframe
5
+ df = pd.DataFrame({
6
+ "A" : [14, 4, 5, 4, 1],
7
+ "B" : [5, 2, 54, 3, 2],
8
+ "C" : [20, 20, 7, 3, 8],
9
+ "D" : [14, 3, 6, 2, 6],
10
+ "E" : [23, 45, 64, 32, 23]
11
+ })
12
+
13
+ # Function to apply text color
14
+ def highlight_cols(x):
15
+ df = x.copy()
16
+ df.loc[:, :] = 'color: purple'
17
+ df[['B', 'C', 'E']] = 'color: green'
18
+ return df
19
+
20
+ # Applying the style function
21
+ s = df.style.apply(highlight_cols, axis = None)
22
+
23
+ # Displaying the styled dataframe in Gradio
24
+ with gr.Blocks() as demo:
25
+ gr.DataFrame(s)
26
+
27
+ demo.launch()