<p>以下选项全部返回序列。创建新框架并列表化。你知道吗</p>
<pre><code>pd.DataFrame(s.tolist()).stack()
0 0 United States of America
1 0 China
1 Hong Kong
dtype: object
</code></pre>
<p>要重置索引,请使用</p>
<pre><code>pd.DataFrame(s.tolist()).stack().reset_index(drop=True)
0 United States of America
1 China
2 Hong Kong
dtype: object
</code></pre>
<p>要转换为数据帧,请调用<code>to_frame()</code></p>
<pre><code>pd.DataFrame(s.tolist()).stack().reset_index(drop=True).to_frame('countries')
countries
0 United States of America
1 China
2 Hong Kong
</code></pre>
<hr/>
<p>如果你想编码高尔夫,使用</p>
<pre><code>sum(s, [])
# ['United States of America', 'China', 'Hong Kong']
pd.Series(sum(s, []))
0 United States of America
1 China
2 Hong Kong
dtype: object
</code></pre>
<p>甚至</p>
<pre><code>pd.Series(np.sum(s))
0 United States of America
1 China
2 Hong Kong
dtype: object
</code></pre>
<p>但是,与大多数其他涉及列表和操作的操作一样,这在性能方面是不好的(列表串联操作效率很低)。你知道吗</p>
<hr/>
<p>使用<code>itertools.chain</code>链接可以实现更快的操作:</p>
<pre><code>from itertools import chain
pd.Series(list(chain.from_iterable(s)))
0 United States of America
1 China
2 Hong Kong
dtype: object
</code></pre>
<p/>
<pre><code>pd.DataFrame(list(chain.from_iterable(s)), columns=['countries'])
countries
0 United States of America
1 China
2 Hong Kong
</code></pre>