gpt4 book ai didi

python - 使用 Pandas 进行数据操作

转载 作者:行者123 更新时间:2023-12-01 08:23:12 26 4
gpt4 key购买 nike

我想复制数据帧中的值直到下一个 NaN。

这是我的数据框:

               Description
0 091SS16 GASOILA THREAD SEALANT
1 NaN
2 NaN
3 NaN
4 NaN
5 NaN
6 NaN
7 3M07447 SCOTCH BRITE PAD
8 NaN
9 NaN
10 NaN
11 NaN
12 NaN
13 NaN
14 NaN
15 600B 6" BUNA-N GASKET

这是我的预期输出:

Description
0 091SS16 GASOILA THREAD SEALANT
1 091SS16 GASOILA THREAD SEALANT
2 091SS16 GASOILA THREAD SEALANT
3 091SS16 GASOILA THREAD SEALANT
4 091SS16 GASOILA THREAD SEALANT
5 091SS16 GASOILA THREAD SEALANT
6 091SS16 GASOILA THREAD SEALANT
7 3M07447 SCOTCH BRITE PAD
8 3M07447 SCOTCH BRITE PAD
9 3M07447 SCOTCH BRITE PAD
10 3M07447 SCOTCH BRITE PAD
11 3M07447 SCOTCH BRITE PAD
12 3M07447 SCOTCH BRITE PAD
13 3M07447 SCOTCH BRITE PAD
14 3M07447 SCOTCH BRITE PAD
15 600B 6" BUNA-N GASKET

请帮忙。谢谢!

最佳答案

您需要 fillnaffill:

df.fillna(ffill)

关于python - 使用 Pandas 进行数据操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54485768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com