Posts

Showing posts from May, 2025

Create Web application using stremlit and AgGrid

 import streamlit as st import numpy as np import pandas as pd import altair as alt from st_aggrid import AgGrid, GridOptionsBuilder from pyspark.sql import SparkSession import re try:     st.set_page_config(layout="wide") except:     pass col1, col2 = st.columns([2,8]) with col1:      st.image('logo.jpg',width=100) spark = SparkSession.builder \ .remote("abc://host:xxx") \ .enableHiveSupport().getOrCreate() #df = spark.sql("SELECT * FROM db.table") @st.cache_data() def load_data():     #df = pd.read_csv('C:/Users/Downloads/xx.csv')     df1 = spark.sql("SELECT * FROM db.table")     df=df1.toPandas()     return df df=load_data() #df=df.toPandas() new_title = '<center><p style="font-family:sans-serif; color:Black; font-size: 20px;><h1 style="text-align:center">Self Service Portal</h1></p></center>' st.markdown(new_title, unsafe_allow_html=True) background_color = "#F0FF...

How to design simple webpage using code studio

  import streamlit as st import pandas as pd import numpy as np import altair as alt import dataiku #st.title('Selfserve reports!') cust_ds = dataiku.Dataset( "name of dataset" ) df = cust_ds.get_dataframe() #create list of countries cntry_lst=df[ "city" ].unique() #create list of countries year_lst=df[ "yearmonth" ].unique() #sel = st.selectbox('Select Market',cntry_lst, key='sel') cust_seg=df[ "customer_segment_current" ].unique() sel=st.multiselect( 'Select City' , cntry_lst, default= None ,key= 'sel' ) yrs=st.multiselect( 'Year(s)' , year_lst, default= None ,key= 'yrs' ) segment=st.multiselect( 'Segment(s)' , cust_seg, default= None ,key= 'seg' ) df = df[df[ "city" ].isin (sel) & df[ "yearmonth" ].isin (yrs)] df2 = df[df[ "customer_segment_current" ].isin (segment)] #Select dim dim = df2[[ 'city' #,'yearmonth' , ...