How to save split data in panda in reverse order?
<p>You can use this to create the dataframe:</p>

<pre><code>xyz = pd.DataFrame({'release' : ['7 June 2013', '2012', '31 January 2013',
                                 'February 2008', '17 June 2014', '2013']})
</code></pre>

<p>I am trying to split the data and save, them into 3 columns named "day, month and year", using this command: </p>

<pre><code>dataframe[['day','month','year']] = dataframe['release'].str.rsplit(expand=True) 
</code></pre>

<p>The resulting dataframe is :
<a href="https://i.stack.imgur.com/695Hd.png" rel="nofollow">dataframe</a></p>

<p>As you can see, that it works perfectly when it gets 3 strings, but whenever it is getting less then 3 strings, it saves the data at the wrong place. </p>

<p>I have tried split and rsplit, both are giving the same result.
Any solution to get the data at the right place?</p>

<p>The last one is year and it is present in every condition , it should be the first one to be saved and then month if it is present otherwise nothing and same way the day should be stored.</p>

<p>Try reversing the result. </p>

<pre><code>dataframe[['year','month','day']] = dataframe['release'].str.rsplit(expand=True).reverse()
</code></pre>

python pandas