Count of selected rows into a variable

Thanks to the Streamlit community. I am able to build an app using aggrid and input csv file without issues.

I am struggling to declare a variable of selected rows grouped by a column as shown in the picture.

I want to use the variable to perform some airthmetic operations based on the number of rows selected in the column.

Any help is appreciated

Thanks and Regards

Hi @Madhav_Kunapareddy

Assuming your aggrid variable is called dta i.e. dta = AgGrid(…
Did you try something like this?
trows= len(dta[“selected_rows”])
st.write(f’Total rows = {trows}’)


Hi Shawn,

Greetings. Thanks for the reply. Apologies for not explaining in more detail.

I have used similar kind of code and was able to write the row count.

But the requirement / my struggle is to write count of rows selected per process area (column in data frame).


Order to Cash 30
Market to Demand 10

Thanks and Regards

Hi Shawn,

Greetings. Thanks so much. However I was able to get the solution with help of another friend.

Thanks and Regards

You are most welcome, @Madhav_Kunapareddy . Would suggest you post the final code here, so that it may help someone else trying to resolve the same issue.


Hi Shawn_Pereira,

Greetings. Please find the below code that worked for me. Thanks to my friend who has helped with this logic.

`if(row_count >0):
  pa = df.groupby(['Process Area']).size().reset_index(name='count')
  paDict = dict(pa.values)
  st.write(paDict['Market to Demand']) 

Thanks and Regards

1 Like