Python> link> 2D array initialization and assignment

Operating environment


GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

I'm trying to read 2D data from a file. I thought about handling it with a 2D array for the future.

Refer to the following for initialization and assignment of 2D array. http://stackoverflow.com/questions/7745562/appending-to-2d-lists-in-python

python_study161223.py


mylist = [[] for idx in range(5)]
mylist[0] = [3, 1]
mylist[2] = [4, 1]
mylist[3] = [5, 9]
print(mylist)

Run


$ python python_study161223.py 
[[3, 1], [], [4, 1], [5, 9], []]

Recommended Posts

Python> link> 2D array initialization and assignment
Python: 3D array image (numpy.array)
Python 2D array trap [Copy array]
Compare Python and JavaScript array loops
python> link> strftime () and strptime () behavior / code
[Python] Summary of array generation (initialization) time! !! !!
Differences between Numpy 1D array [x] and 2D array [x, 1]
Solving with Ruby, Perl, Java and Python AtCoder ABC 131 D Array Sorting
MessagePack-Try to link Java and Python with RPC
Correspondence summary of array operation of ruby and python
Python multidimensional array
[Beginner] Python array
Python array basics
Behavior of numpy.dot when passing 1d array and 2d array
python --Export 2D histogram as an array by Matplotlib
AtCoder ARC080 D simulation solved in Ruby and Python
[Blender x Python] 3D Bouncing Ball and other animations
Try to operate DB with Python and visualize with d3
Implementing a generator using Python> link> yield and next ()> yield
[python] Compress and decompress
python> link> range () / xrange ()
Python and numpy tips
[Python] pip and wheel
Calculate 2D IDCT ~ Python
Batch design and python
Python iterators and generators
[Python] Binary Acing 2020D
[Python] Multi-line string assignment
Ruby, Python and map
python numpy array calculation
python input and output
Python and Ruby split
Python3, venv and Ansible
Python asyncio and ContextVar
python> Link> PyUserInput package |
[python] Array slice operation
AtCoder ABC155 Problem D Pairs Review Note 2 NumPy and Python
Solving with Ruby and Python AtCoder ABC178 D Dynamic programming
How to swap elements in an array in Python, and how to reverse an array.
Solving with Ruby and Python AtCoder ABC151 D Breadth-first search
Python> Difference between inpbt and print (inpbt) output> [1. 2. 3.] / array ([1., 2., 3.], dtype = float32)
Solve with Ruby and Python AtCoder ABC133 D Cumulative sum
[Python] Closures and Unbound LocalError: local variable'x' referenced before assignment
How to transpose a 2D array using only python [Note]
Solving with Ruby and Python AtCoder AISING2020 D Iterative Squares
Solving with Ruby and Python AtCoder ABC138 D Adjacency list