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)