title: Issues when creating a line_chart in streamlit using pandas and extracting values from FreqDist
body: <p>I'm running into issues and not fully understanding how to create a proper line chart with my streamlit app.</p>
  <p>main.py</p>
  <pre><code>st.title(&quot;Project1&quot;)
  st.header(&quot;Part A - The Top Stories API&quot;)
  st.markdown(&quot;This app uses the Top Stories API to display the most common words used in the top current \
          articles based on a specified topic selected by the user. The data is displayed as line chart \
          and as a wordcloud image.&quot;)
  
  st.subheader(&quot;I - Topic Selection&quot;)
  name = st.text_input(&quot;Please enter your name&quot;)
  topic = st.selectbox(
      &quot;Select a topic of your interest&quot;,
      [&quot;arts&quot;, &quot;automobiles&quot;, &quot;books&quot;, &quot;business&quot;, &quot;fashion&quot;, &quot;food&quot;, &quot;health&quot;, &quot;home&quot;,
       &quot;insider&quot;, &quot;magazine&quot;, &quot;movies&quot;, &quot;nyregion&quot;, &quot;obituaries&quot;, &quot;opinion&quot;, &quot;politics&quot;,
       &quot;realestate&quot;, &quot;science&quot;, &quot;sports&quot;, &quot;sundayreview&quot;, &quot;technology&quot;, &quot;theater&quot;, &quot;t-magazine&quot;,
       &quot;travel&quot;, &quot;upshot&quot;, &quot;us&quot;, &quot;world&quot;]
  )
  
  if 'automobiles' in topic:
      st.write(&quot;Hi &quot; + name + &quot;, you selected the &quot; + topic + &quot; topic.&quot;)
  
      api_calls.top_stories_api('automobiles')
  
      st.subheader(&quot;II - Frequency Distribution&quot;)
      if st.checkbox(&quot;Click here to generate frequency distribution&quot;):
          chart_data = pd.DataFrame(
              api_calls.line_graph(),
              columns=['Words', 'Count']
          )
          chart_data = chart_data.set_index('Words')
          st.line_chart(chart_data)
  
      st.subheader(&quot;III - WordCloud&quot;)
      if st.checkbox(&quot;Click here to generate wordcloud&quot;):
          api_calls.wordcloud()
          st.markdown(&quot;&lt;p style='text-align: center;'&gt;Wordcloud generated for &quot; + topic + &quot; topic.&quot;,
                      unsafe_allow_html=True)
  </code></pre>
  <p>api_calls.py</p>
  <pre><code>api_key_dict = main_functions.read_from_file(&quot;JSON_Files/api_keys.json&quot;)
  api_key = api_key_dict[&quot;my_key&quot;]
  
  my_articles = main_functions.read_from_file(&quot;JSON_Files/response.json&quot;)
  
  str1 = &quot;&quot;
  
  for i in my_articles[&quot;results&quot;]:
      str1 = str1 + i[&quot;abstract&quot;]
  
  
  def top_stories_api(topic):
      url = &quot;https://api.nytimes.com/svc/topstories/v2/&quot; + topic + &quot;.json?api-key=&quot; + api_key
      response = requests.get(url).json()
  
      main_functions.save_to_file(response, &quot;JSON_Files/response.json&quot;)
  
  
  def most_popular_api(social, period):
      url = &quot;https://api.nytimes.com/svc/mostpopular/v2/&quot; + social + &quot;/&quot; + period + &quot;.json?api-key=&quot; + api_key
      response = requests.get(url).json()
  
      main_functions.save_to_file(response, &quot;JSON_Files/response.json&quot;)
  
  
  def line_graph():
      from nltk.corpus import stopwords
  
      words = word_tokenize(str1)
  
      words_no_punc = []
  
      for w in words:
          if w.isalpha():
              words_no_punc.append(w.lower())
  
      stopwords = stopwords.words(&quot;english&quot;)
  
      clean_words = []
      for w in words_no_punc:
          if w not in stopwords:
              clean_words.append(w)
  
      fdist3 = FreqDist(clean_words)
      fdist3.most_common(10)
  
      return fdist3
  
  
  def wordcloud():
      wc = WordCloud().generate(str1)
      plt.figure(figsize=(12, 12))
      plt.imshow(wc)
      plt.axis(&quot;off&quot;)
  
      return st.pyplot()
  </code></pre>
  <p>so as you can see, I'm creating a FreqDist to give me 10 most common words and I'd like to use those words as column names, and the frequency as the other axis. I'm not getting any errors however, the line graph is not being displayed.</p>
  <p>Another issue I'm running into is I'd like to loop through the items in the selectbox, so whatever  the user clicks, is what will show up in the line chart. The data should automatically be pulled from response.json. Trying to do this using DRY methods.</p>