1

フォーマットされた文字列を構造化配列に入れる必要があります (文字列は JSON 形式の 2D テーブルで、すべての列は ですobjects)。今、私はそうしています:

import json
import numpy
json_string  = '{"SYM": ["this_string","this_string","this_string"],"DATE": ["NaN","NaN","NaN"],"YEST": ["NaN","NaN","NaN"],"other_DATE": ["NaN","NaN","NaN"],"SIZE": ["NaN","NaN","NaN"],"ACTIVITY": ["2019-09-27 14:18:28.000700 UTC","2019-09-27 14:18:28.000700 UTC","2019-09-27 14:18:28.000600 UTC"]}'
all_content  = json.loads(json_string)
dtype        = numpy.dtype(dict(names = list(all_content.keys()), formats = ['O'] * len(all_content.keys())))
this_bucket  = numpy.empty(shape = [len(all_content[next(iter(all_content.keys()))]), ], 
                                dtype = dtype)
for key in all_content.keys():
    this_bucket[key][:] = all_content[key]

しかし、それは非常に冗長に思えます。直接的な方法はありますか?

4

1 に答える 1