Python 数据帧中存在重复值

Python 数据帧中存在重复值,python,python-3.x,pandas,dataframe,Python,Python 3.x,Pandas,Dataframe,我有一个数据帧,如: doc_id text uci_class tokens lemma pos 1 accès rapide et facile personnel très avenant... 1

我有一个数据帧,如:

 doc_id       text                                       uci_class          tokens                                          lemma                                             pos
   1    accès rapide et facile personnel très avenant...    1        [accès, rapide, et, facile, , personnel, très...   [accès, rapide, et, facile, , personnel, très...    [NOUN, ADJ, CCONJ, VERB, SPACE, ADJ, ADV, VERB...
   2    les petits déjeuners sont les meilleurs que no...   1        [les, petits, déjeuners, sont, les, meilleurs,...  [le, petit, déjeuner, être, le, meilleur, que,...   [DET, ADJ, NOUN, AUX, DET, NOUN, PRON, PRON, A.
我希望在输出中有:

 doc_id       text                                       uci_class          tokens      lemma    pos
   1    accès rapide et facile personnel très avenant...    1                accès       accès   NOUN

   1    accès rapide et facile personnel très avenant...    1                rapide     rapide   ADJ

   1    accès rapide et facile personnel très avenant...    1                et            et   CCONJ

这是一个很好的问题,您可以使用df.explode函数()

像这样使用它

df.explode('tokens')
df.explode('lemma')
df.explode('pos')

签出
df.explode
将需要
df.join
以及@Ch3steR,以通过链接
避免df的多个产品。explode
认为它值得拥有自己的产品answer@Manakin如果每个索引对应的列表长度相同,则
df.apply(pd.Series.explode)
应该这样做。