Convert column object into integer in python
<p>I have this dataset:</p>

<pre><code>training.head()
Out[115]: 
GridID        date      Shift  Accident  
0       1  2010-10-08      Night         0                
1       1  2011-02-16    Morning         0                     
2       1  2014-05-31      Night         0                   
3       1  2011-04-03  Afternoon         0                   
4       1  2013-02-20    Morning         0  
</code></pre>

<p>I would like to replace in column Shift the words "Morning", "Afternoon" and "Night" with integers 1, 2 and 3, repectively.</p>

<p>I tried:</p>

<pre><code>training['Shift'].str.replace('Morninig','1').astype(int)
</code></pre>

<p>But it gives me:</p>

<pre><code> ValueError: invalid literal for int() with base 10: 'Night'
</code></pre>