我有一個熊貓數據幀是這樣的:Pandas DF有一個列表。如何重複此列表的每個值的行?
title author year type
0 t1 a1 1980 article
1 t2 ['a2', 'a3', 'a4'] 1983 article
2 t3 a5 1982 article
3 t4 a6 1977 article
4 t5 ['a7','a8'] 2011 book
這是一個簡短的例子,原來是更加大。
我需要這樣一個數據幀:
title author year type
0 t1 a1 1980 article
1 t2 a2 1983 article
2 t2 a3 1983 article
3 t2 a4 1983 article
4 t3 a5 1982 article
5 t4 a6 1977 article
6 t5 a7 2011 book
7 t5 a8 2011 book
注意,名單有不同數量的元素
的可能的複製http://stackoverflow.com/questions/27263805/pandas- when-cell-contents-are-lists-create-a-row-for-each-element-in-the-list – bigbounty