title: Changing Period to Datetime
body: <h2>My goal is to convert period to datetime.</h2>
  <p><strong>If Life Was Easy:</strong></p>
  <pre><code>master_df = master_df['Month'].to_datetime()
  </code></pre>
  <p><strong>Back Story:</strong></p>
  <p>I built a new dataFrame that originally summed the monthly totals and made a 'Month' column by converting a timestamp to period. Now I want to convert that time period back to a timestamp so that I can create plots using matplotlib.</p>
  <p><a href="https://i.stack.imgur.com/hnJU4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hnJU4.png" alt="enter image description here" /></a></p>
  <p><strong>I have tried following:</strong></p>
  <ul>
  <li><p>Reading the docs for <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Period.to_timestamp.html#pandas.Period.to_timestamp" rel="nofollow noreferrer">Period.to_timestamp</a>.</p>
  </li>
  <li><p>Converting to a string and then back to datetime. Still keeps the period issue and won't convert.</p>
  </li>
  <li><p>Following a couple similar questions in Stackoverflow but could not seem to get it to work.</p>
  </li>
  </ul>
  <p><strong>A simple goal would be to plot the following:</strong></p>
  <pre><code>plot.bar(m_totals['Month'], m_totals['Showroom Visits']);
  </code></pre>
  <p><strong>This is the error I get if I try to use a period dtype in my charts</strong></p>
  <pre><code>ValueError: view limit minimum 0.0 is less than 1 and is an invalid Matplotlib date value. 
  </code></pre>
  <p>This often happens if you pass a non-datetime value to an axis that has datetime units.</p>
  <h2>Additional Material:</h2>
  <p>Code I used to create the <code>Month</code> column (where period issue was created):</p>
  <p><code>master_df['Month'] = master_df['Entry Date'].dt.to_period('M')</code></p>
  <p>Codes I used to group to monthly totals:</p>
  <pre><code>m_sums = master_df.groupby(['DealerName','Month']).sum().drop(columns={'Avg. Response Time','Closing Percent'})
  
  m_means = master_df.groupby(['DealerName','Month']).mean()
  m_means = m_means[['Avg. Response Time','Closing Percent']]
  
  m_totals = m_sums.join(m_means)
  m_totals.reset_index(inplace=True)
  m_totals
  </code></pre>
  <p><strong>Resulting DataFrame:</strong></p>
  <p><a href="https://i.stack.imgur.com/DPRrG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DPRrG.png" alt="enter image description here" /></a></p>