title: Streamlit - Applying value_counts / groupby to column selected on run time
body: <p>I am trying to apply value_counts method to a Dataframe based on the columns selected dynamically in the Streamlit app</p>
  
  <p>This is what I am trying to do:</p>
  
  <pre><code>if st.checkbox("Select Columns To Show"):
      all_columns = df.columns.tolist()
      selected_columns = st.multiselect("Select", all_columns)
      new_df = df[selected_columns]
      st.dataframe(new_df)
  </code></pre>
  
  <p>The above lets me select columns and displays data for the selected columns. I am trying to see how could I apply <code>value_counts</code>/<code>groupby</code> method on this output in Streamlit app</p>
  
  <p>If I try to do the below</p>
  
  <pre><code>st.table(new_df.value_counts())
  </code></pre>
  
  <p>I get the below error</p>
  
  <pre><code>AttributeError: 'DataFrame' object has no attribute 'value_counts'
  </code></pre>