title: Python: how can I get the mode from a month column that i extracted from a datetime column?
body: <p>I'm new at this! Doing my first Python project. :)<br/>
  My tasks are:</p>
  <ol>
  <li>convert df['Start Time'] from string to datetime</li>
  <li>create a month column from df['Start Time']</li>
  <li>get the mode of that month.</li>
  </ol>
  <p>I used a few different ways to do all 3 of the steps, but trying to get the mode always returns <strong>TypeError: tuple indices must be integers or slices, not str</strong>. This happens even if I try converting the &quot;tuple&quot; into a list or NumPy array.</p>
  <p>Ways I tried to extract month from Start Time:</p>
  <pre><code>df['extracted_month'] = pd.DatetimeIndex(df['Start Time']).month
  df['extracted_month'] = np.asarray(df['extracted_month'])
  df['extracted_month'] = df['Start Time'].dt.month
  </code></pre>
  <p>Ways I've tried to get the mode:</p>
  <pre><code>print(df['extracted_month'].mode())
  print(df['extracted_month'].mode()[0])
  print(stat.mode(df['extracted_month']))
  </code></pre>
  <p>Trying to get the index with <strong>df.columns.get_loc(&quot;extracted_month&quot;)</strong> then replacing it in the mode code gives me the SAME error (<strong>TypeError: tuple indices must be integers or slices, not str</strong>).</p>
  <p>I think I should convert df['extracted_month'] into a different... something. What is it?</p>
  <p>Note: My extracted_month column is a STRING, but you should still be able to get the mode from a string variable! I'm not changing it, that would be giving up.</p>
  <p>Edit: using the following code still results in the same error</p>
  <pre><code>extracted_month = pd.Index(df['extracted_month'])
  print(extracted_month.value_counts())
  </code></pre>