title: Pandas - extracting month and year from index
body: <p>I have a dataframe with datetime as index. How can I extract year and month from the index? Below is my dataframe.</p>
  
  <pre><code>            1. open   2. high    3. low  4. close   5. volume
  date                                                         
  2019-01-07   101.64  103.2681  100.9800    102.06  35656136.0
  2019-01-08   103.04  103.9700  101.7134    102.80  31294058.0
  </code></pre>
  
  <p>apparently <code>df["index"].dt.month</code> or <code>df["date"].dt.month</code> doesnt work.</p>