Pandas - change of values of index type
<p>I am working with multiIndex Panda DataFrames. The values of my indices are reported as strings - however, I need to change them to integers or floats to do some calculations with them afterwards.
Is there an efficient way to do this (preferably without for loops as those use up lots of calculation time)?    </p>

<pre><code>import pandas as pd
import numpy as np

idx = pd.IndexSlice
ix = pd.MultiIndex.from_product(
    [['2015', '2016', '2017', '2018'],
     ['2016', '2017', '2018', '2019', '2020'],
     ['A', 'B', 'C']],
    names=['SimulationStart', 'ProjectionPeriod', 'Group']
)

df = pd.DataFrame(np.random.randn(60, 1), index=ix, columns=['Origin'])
origin = df.loc[idx[:, :, :], 'Origin'].values


get_index_values = df.index.get_level_values
projection = get_index_values('ProjectionPeriod')

# This function fails - is there an easy solution for this 
# (preferably without accessing each item at a time in a for loops)?
int(projection)
</code></pre>