friends I have a problem, I create a column based on 2 others that are edited at the time of presentation with aggrid if the column is presented but I want to continue working with the column created and I do not know how to call it, thank you very much for your help.
import streamlit as st
#from st_aggrid import JsCode, AgGrid, GridOptionsBuilder,GridUpdateMode, DataReturnMode
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode, DataReturnMode, JsCode
from st_aggrid.shared import GridUpdateMode
import pandas as pd
df_odoo = pd.DataFrame(odoo)
df_odoo= df_odoo.loc[df_odoo['PAI/NO PAI'] == 'PAI']
#agrupamos las direcciones
direc = st.selectbox('Escoje la dirección que va a realizar la reforma:', options=df_odoo['DIRECCIÓN'].unique())
df_od= df_odoo.loc[df_odoo.DIRECCIÓN == direc].groupby(['PROGRAMA','PROYECTO','Código','Estructura'], as_index= False)[['Codificado', 'Saldo Disponible']].sum()
df_2=df_od
#df_2['Codif Reforma']=df_2['Codificado']*1
df_2['Movimiento']=0
#df_2['New Codificado']=0
st.markdown("---")
st.markdown("<h1 style='text-aling: center;'> REFORMAS </h1>", unsafe_allow_html=True)
gb = GridOptionsBuilder.from_dataframe(df_2)
gb.configure_column('PROGRAMA', hide=True, rowGroup=True, cellRenderer= "agGroupCellRenderer", )
gb.configure_column('PROYECTO', hide=True, rowGroup=True)
gb.configure_column('Estructura')
gb.configure_column('Codificado', aggFunc='sum')
gb.configure_column('Saldo Disponible', aggFunc='sum')
cellsytle_jscode = JsCode("""
function(params) {
if (params.value > '0') {
return {
'color': 'white',
'backgroundColor': 'green'
}
}
else if (params.value < '0'){
return {
'color': 'white',
'backgroundColor': 'darkred'
}
}
else {
return {
'color': 'black',
'backgroundColor': 'white'
}
}
};
""")
gb.configure_column('Movimiento', editable=True, cellStyle=cellsytle_jscode, aggFunc='sum')
gb.configure_column('NewCodificado', valueGetter='Number(data.Codificado) +
Number(data.Movimiento)', cellRenderer='agAnimateShowChangeCellRenderer',
editable=True, type=['numericColumn'], aggFunc='sum')
go = gb.build()
reload_data = False
return_mode_value = DataReturnMode.FILTERED_AND_SORTED
update_mode_value = GridUpdateMode.GRID_CHANGED
ag = AgGrid(
df_2,
gridOptions=go,
height=400,
fit_columns_on_grid_load=True,
data_return_mode=return_mode_value,
update_mode=update_mode_value,
allow_unsafe_jscode=True,
key='an_unique_key_xZs151',
reload_data=reload_data,
try_to_convert_back_to_original_types=False
)
st.subheader("Returned Data")
st.markdown(ag['data'].to_html(), unsafe_allow_html=True)
In this table, the movement column is edited and added to the coded column and the new coded column is created.
I want to print again the table with the modifications and it does not print, in the same way I want to work with the created column and I do not know how to call it.