Python > array > [3, 1, 4, 1, 5], [2, 7, 1, 8, 2] から[[3, 2], [1, 7], [4, 1], [1, 8], [5, 2]]を作る
4579 ワード
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04.4 LTS desktop amd64
TensorFlow v1.7.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)
ADDA v.1.3b6
gnustep-gui-runtime v0.24.0-3.1
PyMieScatt v1.7.0
code v0.1
numpy_array_x_y_to_xy_180415.py
import numpy as np
# on Python 3.5.2
xs = [3, 1, 4, 1, 5]
ys = [2, 7, 1, 8, 2]
res = [[ax, ay] for ax, ay in zip(xs, ys)]
print(res)
run
$ python3 numpy_array_x_y_to_xy_180415.py
[[3, 2], [1, 7], [4, 1], [1, 8], [5, 2]]
code v0.2
@LouiS0616 さんのコメントのとおりNumpyのインポートは不要でした。
コメントありがとうございます。
- ファイル名変更 (numpy除去)
- 記事タイトル変更 (Numpy -> Python)
- タグ変更 (Numpy -> Python)
array_x_y_to_xy_180415.py
# on Python 3.5.2
xs = [3, 1, 4, 1, 5]
ys = [2, 7, 1, 8, 2]
res = [[ax, ay] for ax, ay in zip(xs, ys)]
print(res)
$ python3 array_x_y_to_xy_180415.py
[[3, 2], [1, 7], [4, 1], [1, 8], [5, 2]]
Author And Source
この問題について(Python > array > [3, 1, 4, 1, 5], [2, 7, 1, 8, 2] から[[3, 2], [1, 7], [4, 1], [1, 8], [5, 2]]を作る), 我々は、より多くの情報をここで見つけました https://qiita.com/7of9/items/025cc2aa5a3b16d45908著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .