|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
def printData():
data = getData() # 气象信息
weather_data = {data[0]: [data[1], data[2], data[3], data[4]+"摄氏度", data[5]],
data[6]: [data[7], data[8], data[9], data[10]+"摄氏度", data[11]]
}
index = ("天气", "风向", "风量", "气温", "日出(落)时间")
data_frame = pd.DataFrame(data, index=index)
print(data_frame)
----------------------------------------------------------------------------------
这是天气查询程序的显示部分,但是出现了报错,报错内容如下:
Traceback (most recent call last):
File "F:\python_file\spider_wether.py", line 122, in <module>
main()
File "F:\python_file\spider_wether.py", line 18, in main
printData()
File "F:\python_file\spider_wether.py", line 114, in printData
data_frame = pd.DataFrame(data, index=index)
File "F:\python_file\venv\lib\site-packages\pandas\core\frame.py", line 711, in __init__
mgr = ndarray_to_mgr(
File "F:\python_file\venv\lib\site-packages\pandas\core\internals\construction.py", line 324, in ndarray_to_mgr
_check_values_indices_shape_match(values, index, columns)
File "F:\python_file\venv\lib\site-packages\pandas\core\internals\construction.py", line 393, in _check_values_indices_shape_match
raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shape of passed values is (12, 1), indices imply (5, 1)
如何解决?
求助求助求助 |
|