stacoverflow.comに答えがありました。多次元リストというのは、[1,2,3]ではなくて、[1,[2,3]のようにリストの中にリストがあるものを指します。リストのリストとか、ネストしたリストとか言われています。そういった多次元リストを1次元に平坦化したいときっ ...
Python でリストのリストを平らにする(あるいは連結する)なら、一番よいのは itertools.chain をつかう方法。 おなじことをするのに複数の書きかたがあるとき、基本的には短く書ける方法がよい。そしてすでに実装されているものがあるなら再発明は避けたい。
Flattens JSON objects in Python. flatten_json flattens the hierarchy in your object which can be useful if you want to force your objects into a table.
If iPython notebook is installed on machine, download the flatten.ipynb file and run through the code. Otherwise, the .py is included as well. To run the '.py' file first download it. Then make sure ...