graphlab adding variable columns from existing sframe
<p>I have a SFrame e.g.</p>

<pre><code>a | b
-----
2 | 31 4 5
0 | 1 9
1 | 2 84
</code></pre>

<p>now i want to get following result</p>

<pre><code>a | b      | c | d | e
----------------------
2 | 31 4 5 | 31|4  | 5
0 | 1 9    | 1 | 9 | 0
1 | 2 84   | 2 | 84 | 0
</code></pre>

<p>any idea how to do it?  or maybe i have to use some other tools? </p>

<p>thanks</p>

<pre><code>def customsplit(string,column):
    val = string.split(' ')
    diff = column - len(val)
    val += ['0']*diff
    return val 

a  =  sf['b'].apply(lambda x: customsplit(x,3))
sf['c'] = [i[0] for i in a]
sf['d'] = [i[1] for i in a]
sf['e'] = [i[2] for i in a]

sf
</code></pre>

<p>Output:</p>

<pre><code>a | b      | c | d | e
----------------------
2 | 31 4 5 | 31|4  | 5
0 | 1 9    | 1 | 9 | 0
1 | 2 84   | 2 | 84 | 0
</code></pre>

python pandas graphlab