{"id":336033,"date":"2022-07-22T15:00:22","date_gmt":"2022-07-22T15:00:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=336033"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=336033","title":{"rendered":"<span>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 json-\u0444\u0430\u043b\u043e\u0432 \u0432 pandas<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c 10\u00a0\u0442\u044b\u0441. json-\u0444\u0430\u0439\u043b\u043e\u0432, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b\u043e \u043e\u043a\u043e\u043b\u043e 3\u00a0\u0442\u044b\u0441. \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432. \u041f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 <strong><em>pandas<\/em><\/strong> \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <strong><em>json_normalize <\/em><\/strong>\u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e 10 \u043c\u0438\u043d\u0443\u0442, \u0447\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0433\u043e. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u044b \u0434\u0432\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 json \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0447\u0442\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u043a\u043e\u0434\u0443.    <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:   <\/p>\n<pre><code>from tqdm import tqdm from pathlib import Path import json from multiprocessing import Pool, RLock import pandas as pd import pickle import argparse<\/code><\/pre>\n<p>\u0412\u0435\u0441\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u043b\u043e\u043a\u0438:   <\/p>\n<ol>\n<li>\n<p>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432   <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0443\u0442\u0435\u0439 \u0434\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0445 \u043d\u0430 n \u0433\u0440\u0443\u043f\u043f (\u0414\u043b\u044f n \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432)   <\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 <strong><em>pandas<\/em><\/strong>   <\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435   <\/p>\n<\/li>\n<\/ol>\n<h2>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432   <\/h2>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <strong><em>argparse<\/em><\/strong>. \u041e\u0442\u0434\u0435\u043b\u0438\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043e\u043f\u0438\u0441\u0430\u0432 \u0435\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><em>get_arg_pareser:<\/em><\/strong>   <\/p>\n<pre><code>def get_arg_pareser():      parser = argparse.ArgumentParser(description=             'From json files creates pd.DataFrame')     parser.add_argument('-i', '--input-folder', type=str,                         help='input data folder', required=True)     parser.add_argument('-o', '--output-file', type=str, default=r'output.pickle',                          help='output.pickle')     parser.add_argument('-e', '--n-executors', type=int, default=8,                          help='number of subprocesses (default: 8)')     return parser<\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e \u0432 \u0431\u043b\u043e\u043a\u0435 __main__:   <\/p>\n<pre><code>    args = get_arg_pareser().parse_args()      N_GROUPS = args.n_executors     jsons_folder_path = args.input_folder     output_file = args.output_file<\/code><\/pre>\n<h2>\u041f\u0443\u0442\u0438 \u0434\u043e \u0444\u0430\u0439\u043b\u043e\u0432   <\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <strong><em>Pathlib<\/em><\/strong> \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u0441\u0435 \u043f\u0443\u0442\u0438 \u0434\u043e \u043d\u0430\u0448\u0438\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432:   <\/p>\n<pre><code>f_paths = list(Path(jsons_folder_path).glob('*.json'))<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 n \u0447\u0430\u0441\u0442\u0435\u0439, \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e (\u0414\u043b\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430).<\/p>\n<pre><code>    in_group = len(f_paths) \/\/ N_GROUPS + 1     inp_args = [f_paths[i:i + in_group] for i in range(0, len(f_paths), in_group)]     inp_args = list(enumerate(inp_args))<\/code><\/pre>\n<h2>\u0420\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 (\u0444\u0443\u043d\u043a\u0446\u0438\u0438). \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><em>one_process_execution<\/em><\/strong>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432\u0441\u0435 json \u0444\u0430\u0439\u043b\u044b \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0434\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 (indexes) \u0438 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 (res_array). \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><em>pd.json_normalize <\/em><\/strong>\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043c \u0438\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u0430\u043a \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><em>json_normalize <\/em><\/strong>\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0430 \u043d\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 pandas \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0438 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 pd.DataFrame \u043f\u043e \u0441\u0442\u0440\u043e\u0447\u043a\u0435, \u0442\u043e \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 3 \u0440\u0430\u0437\u0430. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e \u0432 pandas, \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u0443 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u0434\u043d\u0435\u0435.<\/p>\n<pre><code>def one_process_execution(pid, f_paths):      res_arr = []     indexes = []      tqdm_text = '#' + f'{pid}'.zfill(3)     with tqdm(total=len(f_paths), position=pid+1, desc=tqdm_text) as pbar:         for path in f_paths:             with open(str(path), 'r') as f:                 d = json.load(f)                  indexes.append(path.stem)                 res_arr.append(d)                  pbar.update(1)     df = pd.json_normalize(res_arr).assign(index=indexes).set_index('index')     print(f'Subproc {pid} done')     return df<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0435\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u2013 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0443\u043b\u0430 (\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430) \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <strong><em>multiprocessing<\/em><\/strong>. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <strong><em>Pool<\/em><\/strong> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0437\u0430\u0434\u0430\u0447, \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u044d\u0442\u043e\u0442 \u043f\u0443\u043b \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><em>one_process_execution<\/em><\/strong> \u0441 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0448\u0430\u0433\u0435 1. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <strong><em>apply_async<\/em><\/strong>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.   <\/p>\n<pre><code>    pool = Pool(processes=N_GROUPS, initializer=tqdm.set_lock, initargs=(RLock(),))     jobs = [pool.apply_async(one_process_execution, args=x) for x in inp_args]<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <strong><em>apply_async<\/em><\/strong> \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0430 \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong><em>jobs<\/em><\/strong> \u0443 \u043d\u0430\u0441 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <strong><em>get<\/em><\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e \u043c\u0435\u0440\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<pre><code>    # run pool     df_lists = list(map(lambda x: x.get(), jobs))<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/263\/181\/351\/26318135192410e7b0b1069cf344ebfb.png\" alt=\"\u0421\u0442\u0430\u0442\u0443\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" title=\"\u0421\u0442\u0430\u0442\u0443\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" width=\"1567\" height=\"165\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/263\/181\/351\/26318135192410e7b0b1069cf344ebfb.png\"\/><figcaption>\u0421\u0442\u0430\u0442\u0443\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/figure>\n<h2>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435   <\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u043e \u0437\u0430 \u043c\u0430\u043b\u044b\u043c: \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u044b \u0432 \u043e\u0434\u0438\u043d \u0435\u0434\u0438\u043d\u044b\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c:   <\/p>\n<pre><code>    res_df = pd.concat(df_lists)      # save     with open(output_file, 'wb') as f:         pickle.dump(res_df, f)<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0441\u043a\u0440\u0438\u043f\u0442, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e json \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u0414\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0430 \u0442\u0435 \u0436\u0435 10 \u0442\u044b\u0441\u044f\u0447 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0437\u0430 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0441\u043a\u043e\u0440\u0438\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 5 \u0440\u0430\u0437.   <\/p>\n<p>\u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u043e\u0435\u0439 \u043b\u0438\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 <a href=\"https:\/\/github.com\/aksesss\/json2pandas\" rel=\"noopener noreferrer nofollow\">github<\/a>. \u041e\u043d \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432 \u0434\u0432\u0443\u0445 \u0440\u0435\u0436\u0438\u043c\u0430\u0445:   <\/p>\n<ol>\n<li>\n<p>\u041a\u0430\u043a \u0441\u043a\u0440\u0438\u043f\u0442, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u043a <strong><em>pickle<\/em><\/strong> \u0444\u0430\u0439\u043b   <\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f main \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <strong><em>pd.DataFrame<\/em><\/strong>   <\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/678384\/\"> https:\/\/habr.com\/ru\/post\/678384\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c 10\u00a0\u0442\u044b\u0441. json-\u0444\u0430\u0439\u043b\u043e\u0432, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b\u043e \u043e\u043a\u043e\u043b\u043e 3\u00a0\u0442\u044b\u0441. \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432. \u041f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 <strong><em>pandas<\/em><\/strong> \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <strong><em>json_normalize <\/em><\/strong>\u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e 10 \u043c\u0438\u043d\u0443\u0442, \u0447\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0433\u043e. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u044b \u0434\u0432\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 json \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0447\u0442\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u043a\u043e\u0434\u0443.    <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:   <\/p>\n<pre><code>from tqdm import tqdm from pathlib import Path import json from multiprocessing import Pool, RLock import pandas as pd import pickle import argparse<\/code><\/pre>\n<p>\u0412\u0435\u0441\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u043b\u043e\u043a\u0438:   <\/p>\n<ol>\n<li>\n<p>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432   <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0443\u0442\u0435\u0439 \u0434\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0445 \u043d\u0430 n \u0433\u0440\u0443\u043f\u043f (\u0414\u043b\u044f n \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432)   <\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 <strong><em>pandas<\/em><\/strong>   <\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435   <\/p>\n<\/li>\n<\/ol>\n<h2>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432   <\/h2>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <strong><em>argparse<\/em><\/strong>. \u041e\u0442\u0434\u0435\u043b\u0438\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043e\u043f\u0438\u0441\u0430\u0432 \u0435\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><em>get_arg_pareser:<\/em><\/strong>   <\/p>\n<pre><code>def get_arg_pareser():      parser = argparse.ArgumentParser(description=             'From json files creates pd.DataFrame')     parser.add_argument('-i', '--input-folder', type=str,                         help='input data folder', required=True)     parser.add_argument('-o', '--output-file', type=str, default=r'output.pickle',                          help='output.pickle')     parser.add_argument('-e', '--n-executors', type=int, default=8,                          help='number of subprocesses (default: 8)')     return parser<\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e \u0432 \u0431\u043b\u043e\u043a\u0435 __main__:   <\/p>\n<pre><code>    args = get_arg_pareser().parse_args()      N_GROUPS = args.n_executors     jsons_folder_path = args.input_folder     output_file = args.output_file<\/code><\/pre>\n<h2>\u041f\u0443\u0442\u0438 \u0434\u043e \u0444\u0430\u0439\u043b\u043e\u0432   <\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <strong><em>Pathlib<\/em><\/strong> \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u0441\u0435 \u043f\u0443\u0442\u0438 \u0434\u043e \u043d\u0430\u0448\u0438\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432:   <\/p>\n<pre><code>f_paths = list(Path(jsons_folder_path).glob('*.json'))<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 n \u0447\u0430\u0441\u0442\u0435\u0439, \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e (\u0414\u043b\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430).<\/p>\n<pre><code>    in_group = len(f_paths) \/\/ N_GROUPS + 1     inp_args = [f_paths[i:i + in_group] for i in range(0, len(f_paths), in_group)]     inp_args = list(enumerate(inp_args))<\/code><\/pre>\n<h2>\u0420\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 (\u0444\u0443\u043d\u043a\u0446\u0438\u0438). \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><em>one_process_execution<\/em><\/strong>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432\u0441\u0435 json \u0444\u0430\u0439\u043b\u044b \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0434\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 (indexes) \u0438 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 (res_array). \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><em>pd.json_normalize <\/em><\/strong>\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043c \u0438\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u0430\u043a \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><em>json_normalize <\/em><\/strong>\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0430 \u043d\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 pandas \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0438 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 pd.DataFrame \u043f\u043e \u0441\u0442\u0440\u043e\u0447\u043a\u0435, \u0442\u043e \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 3 \u0440\u0430\u0437\u0430. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e \u0432 pandas, \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u0443 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u0434\u043d\u0435\u0435.<\/p>\n<pre><code>def one_process_execution(pid, f_paths):      res_arr = []     indexes = []      tqdm_text = '#' + f'{pid}'.zfill(3)     with tqdm(total=len(f_paths), position=pid+1, desc=tqdm_text) as pbar:         for path in f_paths:             with open(str(path), 'r') as f:                 d = json.load(f)                  indexes.append(path.stem)                 res_arr.append(d)                  pbar.update(1)     df = pd.json_normalize(res_arr).assign(index=indexes).set_index('index')     print(f'Subproc {pid} done')     return df<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0435\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u2013 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0443\u043b\u0430 (\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430) \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <strong><em>multiprocessing<\/em><\/strong>. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <strong><em>Pool<\/em><\/strong> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0437\u0430\u0434\u0430\u0447, \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u044d\u0442\u043e\u0442 \u043f\u0443\u043b \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><em>one_process_execution<\/em><\/strong> \u0441 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0448\u0430\u0433\u0435 1. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <strong><em>apply_async<\/em><\/strong>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.   <\/p>\n<pre><code>    pool = Pool(processes=N_GROUPS, initializer=tqdm.set_lock, initargs=(RLock(),))     jobs = [pool.apply_async(one_process_execution, args=x) for x in inp_args]<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <strong><em>apply_async<\/em><\/strong> \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0430 \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong><em>jobs<\/em><\/strong> \u0443 \u043d\u0430\u0441 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <strong><em>get<\/em><\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e \u043c\u0435\u0440\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<pre><code>    # run pool     df_lists = list(map(lambda x: x.get(), jobs))<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><figcaption>\u0421\u0442\u0430\u0442\u0443\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/figure>\n<h2>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435   <\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u043e \u0437\u0430 \u043c\u0430\u043b\u044b\u043c: \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u044b \u0432 \u043e\u0434\u0438\u043d \u0435\u0434\u0438\u043d\u044b\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c:   <\/p>\n<pre><code>    res_df = pd.concat(df_lists)      # save     with open(output_file, 'wb') as f:         pickle.dump(res_df, f)<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0441\u043a\u0440\u0438\u043f\u0442, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e json \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u0414\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0430 \u0442\u0435 \u0436\u0435 10 \u0442\u044b\u0441\u044f\u0447 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0437\u0430 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0441\u043a\u043e\u0440\u0438\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 5 \u0440\u0430\u0437.   <\/p>\n<p>\u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u043e\u0435\u0439 \u043b\u0438\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 <a href=\"https:\/\/github.com\/aksesss\/json2pandas\" rel=\"noopener noreferrer nofollow\">github<\/a>. \u041e\u043d \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432 \u0434\u0432\u0443\u0445 \u0440\u0435\u0436\u0438\u043c\u0430\u0445:   <\/p>\n<ol>\n<li>\n<p>\u041a\u0430\u043a \u0441\u043a\u0440\u0438\u043f\u0442, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u043a <strong><em>pickle<\/em><\/strong> \u0444\u0430\u0439\u043b   <\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f main \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <strong><em>pd.DataFrame<\/em><\/strong>   <\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/678384\/\"> https:\/\/habr.com\/ru\/post\/678384\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-336033","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=336033"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336033\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}