<p>拆分列名以生成新的列名,然后使用param^{cd3>}调用向量化的<a href="http://pandas.pydata.org/pandas-docs/stable/api.html#string-handling" rel="nofollow">^{<cd1>}</a><a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.split.html#pandas.Series.str.split" rel="nofollow">^{<cd2>}</a>方法:</p>
<pre><code>In [26]:
cols = 'curv_typ,maturity,bonds,geo\\time'.split(',')
df[cols] = df['curv_typ,maturity,bonds,geo\\time'].str.split(',', expand=True)
df
Out[26]:
curv_typ,maturity,bonds,geo\time 2015M06D16 2015M06D15 2015M06D11 \
0 PYC_RT,Y1,GBAAA,EA -0.24 -0.24 -0.24
1 PYC_RT,Y1,GBA_AAA,EA -0.02 -0.03 -0.10
2 PYC_RT,Y10,GBAAA,EA 0.94 0.92 0.99
3 PYC_RT,Y10,GBA_AAA,EA 1.67 1.70 1.60
4 PYC_RT,Y11,GBAAA,EA 1.03 1.01 1.09
curv_typ maturity bonds geo\time
0 PYC_RT Y1 GBAAA EA
1 PYC_RT Y1 GBA_AAA EA
2 PYC_RT Y10 GBAAA EA
3 PYC_RT Y10 GBA_AAA EA
4 PYC_RT Y11 GBAAA EA
</code></pre>
<p><strong>编辑</strong></p>
<p>对于pandas版本<code>0.16.0</code>及更早版本,则需要使用以下行:</p>
^{pr2}$