gpt4 book ai didi

Python, Pandas - ValueError : Shape of passed values is (1, 5), indices imply (5, 5)

转载 作者:太空宇宙 更新时间:2023-11-04 04:34:55 34 4
gpt4 key购买 nike

我试图捕捉一个进入 Pandas 数据框的空列表,但发生了上述错误:

ValueError: Shape of passed values is (1, 5), indices imply (5, 5)

我目前在这里有一个简单的设置:

if not daily_info:
daily_info= ["No data found today","No data found today","No data found today","No data found today","No data found today"]
df = pd.DataFrame(data=daily_info, columns=['Send/Collect', 'Hospital', 'Courier', 'Kit', 'Manufacturer'])
df = df.assign(Status="Not Started")

这可能看起来类似于 this它询问有关附加现有 DF 的地方,但答案并不能真正帮助我处理不同的上下文。

谁能帮我看看我哪里做错了?

最佳答案

我认为需要将嵌套的 list 传递给 DataFrame 构造函数 - [daily_info]:

daily_info= ["No data found today","No data found today","No data found today","No data found today","No data found today"]
df = pd.DataFrame(data=[daily_info], columns=['Send/Collect', 'Hospital', 'Courier', 'Kit', 'Manufacturer'])
df = df.assign(Status="Not Started")
print (df)
Send/Collect Hospital Courier \
0 No data found today No data found today No data found today

Kit Manufacturer Status
0 No data found today No data found today Not Started

关于Python, Pandas - ValueError : Shape of passed values is (1, 5), indices imply (5, 5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51948148/

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