Hi
I would remove the warnings import and the warnings.filterwarnings() line. These lines are used to suppress a warning that is raised by the pygwalker library.
You can test this correction:
import numpy as np
import pandas as pd
import streamlit.components.v1 as stc
import pygwalker as pyg
import streamlit as st
st.set_page_config(layout=âwideâ,
page_title=âPruebaâ,
page_icon=ââđâ)
def PYG_WALKER(TEXT_DATA, CAT_DATA, START_D, END_D, Y_DATA):
DATA = pd.DataFrame()
if len(TEXT_DATA) != 0:
TC = TEXT_DATA.columns
DATA[TC] = TEXT_DATA
if len(CAT_DATA) != 0:
CAT_col = list(CAT_DATA.columns)
DATA[CAT_col] = CAT_DATA[CAT_col]
if len(START_D) != 0:
START_D_col = START_D.name
DATA[START_D_col] = START_D
if len(END_D) != 0:
END_D_col = END_D.name
DATA[END_D_col] = END_D
if len(Y_DATA) != 0:
Y_DATA = pd.DataFrame(Y_DATA)
Y_col = list(Y_DATA.columns)[0]
DATA[Y_col] = Y_DATA[Y_col]
for col in DATA.columns:
try:
DATA[col] = DATA[col].replace("NO-VALUE", np.nan)
try:
DATA[col] = DATA[col].replace("", np.nan)
except:
pass
except:
pass
pyg_html = pyg.walk(DATA, env='streamlit', return_html=True)
stc.html(pyg_html, scrolling=True, height=920)
Creamos los datos
TEXT_DATA = pd.DataFrame({
âtextâ: [âEste es un textoâ, âEste es otro textoâ, âEste es un texto mĂĄs largoâ]
})
CAT_DATA = pd.DataFrame({
âcategorĂaâ: [âcategorĂa 1â, âcategorĂa 2â, âcategorĂa 3â]
})
START_D = pd.Series([â2023-07-20â, â2023-07-21â, â2023-07-22â])
END_D = pd.Series([â2023-07-21â, â2023-07-22â, â2023-07-23â])
Y_DATA = pd.Series([1, 2, 3])
Ejecutamos la funciĂłn
PYG_WALKER(TEXT_DATA, CAT_DATA, START_D, END_D, Y_DATA)