How can I convert a categorical index to a float?
<p>I have a categorical index of wind directions in a pandas dataframe.</p>

<pre><code>print (self.Groups.index)

CategoricalIndex([22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5],
categories=[22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5],
ordered=True, name='Dir', dtype='category')
</code></pre>

<p>I am trying to use this index to plot a wind rose eg.</p>

<pre><code> ax.bar(self.Groups.index,self.Groups['wind_speed'])
</code></pre>

<p>but I need to convert the index to radians for it to properly display on a polar plot.</p>

<p>Is there a way to convert the the Categorical index to a float?</p>

<p>Use <code>astype</code> to perform the conversion:</p>

<pre><code>self.Groups.index = self.Groups.index.astype('float')
</code></pre>

python pandas