how to split 'number' to separate columns in pandas DataFrame
<p>I have a dataframe;</p>

<pre><code>df=pd.DataFrame({'col1':[100000,100001,100002,100003,100004]})

     col1    
0   100000    
1   100001
2   100002
3   100003
4   100004
</code></pre>

<p>I wish I could get the result below;</p>

<pre><code>    col1   col2    col3
0   10     00       00 
1   10     00       01
2   10     00       02
3   10     00       03
4   10     00       04
</code></pre>

<p>each rows show the splitted number. I guess the number should be converted to string, but I have no idea next step....
I wanna ask how to split number to separate columns.</p>

<p>One option is to use <code>extractall()</code> method with regex <code>(\d{2})(\d{2})(\d{2})</code> which captures every other two digits as columns. <code>?P&lt;col1&gt;</code> is the name of the captured group which will be converted to the column names:</p>

<pre><code>df.col1.astype(str).str.extractall("(?P&lt;col1&gt;\d{2})(?P&lt;col2&gt;\d{2})(?P&lt;col3&gt;\d{2})").reset_index(drop=True)

#   col1  col2  col3
# 0   10    00    00
# 1   10    00    01
# 2   10    00    02
# 3   10    00    03
# 4   10    00    04
</code></pre>

python pandas numpy dataframe split