[PYTHON] [Updated from time to time] Review of Let Code NumPy

np.zeros

#int type n rows m columns
l_2d = np.zeros((n,m), dtype=int)

Extracting elements

# index:[0,1] 
# l_2d:[[0, 0, 0], [0, 0, 0]]
for index in indices: 
            l_2d[index[0],:] += 1
            l_2d[:,index[1]] += 1
            print(l_2d)

Element bool value

l_2d = np.zeros((n,m), dtype=int)
print(l_2d % 2 != 0)

True number of bool values for the element

np.count_nonzero(l_2d % 2 != 0)

Recommended Posts

[Updated from time to time] Review of Let Code NumPy
Summary of vtkThreshold (updated from time to time)
Summary of gcc options (updated from time to time)
Machine learning python code summary (updated from time to time)
vtkOpenFOAMReader Summary (Updated from time to time)
Engineer vocabulary (updated from time to time)
Tensorflow memo [updated from time to time]
[Updated from time to time] Summary of design patterns in Java
(Updated from time to time) Storage location of various VS Code configuration files Memorandum memo
[Notes / Updated from time to time] This and that of Azure Functions
Private Python handbook (updated from time to time)
vtkClipPolyData / DataSet Summary (Updated from time to time)
[Updated from time to time] PostmarketOS related notes
Let Code Day6 Starting from Zero "1342. Number of Steps to Reduce a Number to Zero"
[Updated from time to time] LetCode algorithm and library
Notes on machine learning (updated from time to time)
Let Code Table of Contents Starting from Zero
OpenFOAM post-processing cheat sheet (updated from time to time)
progate Python learning memo (updated from time to time)
Useful help sites, etc. (updated from time to time)
Let Code Day 19 Starting from Zero "121. Best Time to Buy and Sell Stock"
Apache settings, log confirmation, etc. (* Updated from time to time)
Convert elements of numpy array from float to int
I read the Chainer reference (updated from time to time)
Let Code Day68 starting from scratch "709. To Lower Case"
A memorandum of commands, packages, terms, etc. used in linux (updated from time to time)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Let Code Day 44 "543. Diameter of Binary Tree" starting from zero
Let Code Day4 starting from scratch "938. Range Sum of BST"
Let Code Day87 Starting from Zero "1512. Number of Good Pairs"
List of my articles that may be useful in competition pros (updated from time to time)
Summary of folders where Ruby, Python, PostgreSQL, etc. are installed on macOS (updated from time to time)
Let Code Day56 Starting from Zero "5453. Running Sum of 1d Array"
Let Code Day7 starting from zero "104. Maximum Depth of Binary Tree"
Let Code Day92 Starting from Zero "4. Median of Two Sorted Arrays"
Let Code Day5 starting from zero "1266. Minimum Time Visiting All Points"
Python (from first time to execution)
Migrate from VS Code to PyCharm
[Note] AI / machine learning / python related websites [updated from time to time]
Review from git init to git push
Let Code Day 35 "160. Intersection of Two Linked Lists" Starting from Zero
Let Code Day 40 Starting from Zero "114. Flatten Binary Tree to Linked List"
From re-environment construction of Python to graph drawing (on visual studio code)
For the first time in Numpy, I will update it from time to time
Let Code Day 11 Starting from Zero "1315. Sum of Nodes with Even-Valued Grandparent"
Let Code Day75 starting from scratch "15.3 Sum"
Easy conversion from UTC to local time
Let Code Day 29 "46. Permutations" starting from scratch
From Attention of Zero Tsuku 2 to Transformer
Flow from source code to creating executable
Introduction to Scapy ① (From installation to execution of Scapy)
Use linter to reduce code review costs
(Updated from time to time) Summary of machine learning APIs that allow you to quickly build apps by Team AI
(Preserved version: Updated from time to time) A collection of useful tutorials for data analysis hackathons by Team AI
Let Code Day 90 starting from scratch "101 11. Capacity To Ship Packages Within D Days"
Let Code Day10 Starting from Zero "1431. Kids With the Greatest Number of Candies"
Let Code Day58 Starting from Zero "20. Valid Parentheses"
Let Code Day 27 "101. Symmetric Tree" starting from scratch
Let Code Day 62 "83. Remove Duplicates from Sorted List"
Convert data with shape (number of data, 1) to (number of data,) with numpy.
Let Code Day16 Starting from Zero "344. Reverse String"