<p>通过<code>re</code>模块和<em>生成器</em>表达式:</p>
<p>假设我们每年都有数据。你知道吗</p>
<pre><code>In [60]: import re
In [61]: lst = ['2018\t \t7,107\t4,394\t2,713', '2017\t \t16,478\t10,286\t6,192', '2016\t \t15,944\t9,971\t5,973', '2015\t \t15,071\t9,079\t5,992', '
...: 2014\t \t14,415\t8,596\t5,819', '2013\t \t14,259\t8,269\t5,990', '2012\t \t14,010\t8,143\t5,867', '2011\t \t14,149\t8,126\t6,023', '2010\t
...: \t14,505\t7,943\t6,562', '2009\t \t14,632\t8,022\t6,610', '2008\t \t14,207\t7,989\t6,218', '2007\t \t14,400\t8,085\t6,315', '2006\t \t14,750
...: \t8,017\t6,733', '2005\t \t14,497\t7,593\t6,904', '2004\t \t14,155\t7,150\t7,005', '2003\t \t13,285\t6,457\t6,828', '2002\t \t12,821\t6,190\
...: t6,631', '2001\t \t12,702\t6,080\t6,622', '2000\t \t11,942\t5,985\t5,957', '1999\t \t10,872\t5,824\t5,048', '1998\t \t10,362\t5,793\t4,569'
...: , '1997\t \t9,546\t5,479\t4,067', '1996\t \t9,222\t5,418\t3,804', '1995\t \t8,859\t5,363\t3,496', '1994\t \t8,203\t5,099\t3,104', '1993\t \t
...: 7,766\t4,861\t2,905', '1992\t \t7,091\t4,520\t2,571', '1991\t \t6,953\t4,526\t2,427', '1990\t \t6,632\t4,509\t2,123', '1989\t \t5,929\t4,011
...: \t1,918', '1988\t \t5,909\t4,080\t1,829']
In [62]: pat = re.compile(r'[^\s]+')
In [63]: parsed = (pat.findall(i) for i in lst)
In [64]: df = pd.DataFrame({i[0] : i[1:] for i in parsed})
In [65]: df
Out[65]:
1988 1989 1990 1991 1992 1993 1994 1995 1996 ... 2010 2011 2012 2013 2014 2015 2016 2017 2018
0 5,909 5,929 6,632 6,953 7,091 7,766 8,203 8,859 9,222 ... 14,505 14,149 14,010 14,259 14,415 15,071 15,944 16,478 7,107
1 4,080 4,011 4,509 4,526 4,520 4,861 5,099 5,363 5,418 ... 7,943 8,126 8,143 8,269 8,596 9,079 9,971 10,286 4,394
2 1,829 1,918 2,123 2,427 2,571 2,905 3,104 3,496 3,804 ... 6,562 6,023 5,867 5,990 5,819 5,992 5,973 6,192 2,713
[3 rows x 31 columns]
</code></pre>