File tree Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Original file line number Diff line number Diff line change 1- import numpy as np
2- import pandas as pd
31import streamlit as st
4- from streamlit_condition_tree import condition_tree , config_from_dataframe
2+ import pandas as pd
53
6- df = pd .read_csv (
7- 'https://drive.google.com/uc?id=1phaHg9objxK2MwaZmSUZAKQ8kVqlgng4&export=download' ,
8- index_col = 0 ,
9- parse_dates = ['Date of birth' ],
10- date_format = '%Y-%m-%d' )
11- df ['Age' ] = ((pd .Timestamp .today () - df ['Date of birth' ]).dt .days / 365 ).astype (int )
12- df ['Sex' ] = pd .Categorical (df ['Sex' ])
13- df ['Likes tomatoes' ] = np .random .randint (2 , size = df .shape [0 ]).astype (bool )
4+ from streamlit_condition_tree import condition_tree , config_from_dataframe
145
15- st .dataframe (df )
6+ # Initial dataframe
7+ df = pd .DataFrame ({
8+ 'First Name' : ['Georges' , 'Alfred' ],
9+ 'Age' : [45 , 98 ],
10+ 'Favorite Color' : ['Green' , 'Red' ],
11+ 'Like Tomatoes' : [True , False ]
12+ })
1613
14+ # Basic field configuration from dataframe
1715config = config_from_dataframe (df )
1816
19- return_val = condition_tree (
17+ # Condition tree
18+ query_string = condition_tree (
2019 config ,
20+ always_show_buttons = True
2121)
2222
23- st .code (return_val )
24-
25- df = df .query (return_val )
26- st .dataframe (df )
23+ # Filtered dataframe
24+ df = df .query (query_string )
You can’t perform that action at this time.
0 commit comments