我有一个数据框,如下所示:
Name Description Count
a This is a 3
b This is b 2
c This is c 1
我要修改此数据框,如下所示:
Name Description Count
a This is a 1
a This is a 1
a This is a 1
b This is b 1
b This is b 1
c This is c 1
基本上,按特定列的值复制每一行。
是python的新手,还不熟悉库。
答案 0 :(得分:3)
尝试reindex
和repeat
df=df.reindex(df.index.repeat(df.Count)).assign(Count=1)