gpt4 book ai didi

python - Pandas :FutureWarning:将喜欢的列表传递给 .loc 或 []

转载 作者:太空宇宙 更新时间:2023-11-03 15:45:23 38 4
gpt4 key购买 nike

<分区>

当我运行我的脚本时,Pandas 给出以下信息:“ future 警告”

FutureWarning:
Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.

我的脚本:

import io

data = io.StringIO('''A,B,M
AM,1,
AMC,2,
''')
df = pd.read_csv(data)

r=['CAR']
s=['CAR_M']

for i,j in zip(r,s):
df=df.append([{'A':i,'M':j}], ignore_index=True)

如果“ignore_index=False”,则会出现相同的警告。我不知道如何重建索引?

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