擅长:python、mysql、java
<p>你可以用<code>apply</code></p>
<pre><code>In [98]: df.attributes.apply(pd.Series)
Out[98]:
firstname id lastname
0 Joe 1 Lee
1 Brian 12 Li
2 Ron 2 Stein
</code></pre>
<p>将结果连接到原始<code>df</code></p>
<pre><code>In [99]: df.join(df.attributes.apply(pd.Series))
Out[99]:
attributes firstname id lastname
0 {u'lastname': u'Lee', u'id': 1, u'firstname': ... Joe 1 Lee
1 {u'lastname': u'Li', u'id': 12, u'firstname': ... Brian 12 Li
2 {u'lastname': u'Stein', u'id': 2, u'firstname'... Ron 2 Stein
In [100]: dff = df.join(df.attributes.apply(pd.Series))
</code></pre>
<p>访问<code>firstname</code></p>
<pre><code>In [101]: dff.firstname
Out[101]:
0 Joe
1 Brian
2 Ron
Name: firstname, dtype: object
</code></pre>