返回

python——为什么我的列表形状在并发期货循环中发生变化?

发布时间:2022-09-07 12:40:13 324
# node.js

有人能告诉我为什么我第二次循环我可以格式化我的 numpy 列表吗?这是我得到的错误。

(venv) C:\Users\ENG-DESKTOP-4\PycharmProjects\Delay Tracker>python -m flight_weather_1

Shape of list is : (500, 1, 10) 

shape of unformatted numpy is (500, 1, 10)

shape of formatted numpy is (500, 10)

Shape of list is : (500,)

shape of unformatted numpy is (500,)

回溯(最后一次调用):文件“C:\Program Files\Python38\lib\runpy.py”,第 194 行,在 _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\Python38\lib \runpy.py”,第 87 行,在 _run_code exec(code, run_globals) 文件“C:\Users\ENG-DESKTOP-4\PycharmProjects\Delay Tracker\flight_weather_1.py”,第 121 行,在 results_formatted = results_thou.reshape( 500, 10)

ValueError:无法将大小为 500 的数组重塑为形状 (500,10)



def index_weather(index):
    Iata_ = (first_mil.iloc[index]['ORIGIN'])
    flight_time_ = (first_mil.iloc[index]['FL_DATE'])
    weather_data = weather_from_IATA(Iata_, flight_time_)
    return weather_data


for i in range(2):
    index_ = list(range(1 + (i * 500), (500 + 1) + (i * 500)))

    with concurrent.futures.ThreadPoolExecutor() as executor:
        secs = index_
        results = executor.map(index_weather, secs)
        results_list = list(results)
        print("Shape of list is : " + str(np.shape(results_list)))
        results_thou = np.array(results_list)

        results_list.clear()

        print("shape of unformatted numpy is", np.shape(results_thou))
        results_formatted = results_thou.reshape(500, 10)
        print("shape of formatted numpy is", np.shape(results_formatted))
        results_pd = pd.DataFrame(results_formatted)
        pd.concat((all2, results_pd), axis=0)
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(2)
按点赞数排序
用户头像