Converting month to quarter in Pandas dataframe
<p>I have a column in my data frame denoting month (in the form <code>yyyy-mm</code>). I want to convert that to quarter using <code>pd.Period</code>.
I tried using apply function in below form but it's running too slow. Is there a better way to do this?
I am using :</p>

<pre><code>hp2['Qtr'] = hp2.apply(lambda x: pd.Period(x['Mth'],'Q'),axis=1)
</code></pre>