Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Series.apply + Lambda Function¶
DataFrame.apply + Lambda Function¶
axis=1: apply the lambda function on each row
List Comprehension¶
numpy.where¶
numpy.where is vectorized ifelse.
Could Not Build Wheels for Numpy Which Use Pep 517
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
This is due to outdated version of pip. Update your pip to the latest version should fix the issue.
pip3 install -U pip
References
Numpy Arrays in Python
Tips and Traps¶
The Pythonic way of checking whether a collection (string, list, set, dict, etc.)
coll
is non-empty is to useif coll
. However, do NOT useif arr
to check whether a numpy array is non-empty or not. Instead, you shoule usearr.size >0
to check whether a numpy array is non-empty or not.
Load Images into Pillow
Get Index of True Values of a Sequence in Python
Using Boolean Indexing¶
Broadcast Arrays in Numpy
Tips and Traps¶
The broadcast concept in numpy is essentially a way to "virtually" duplicate data in a numpy array so that it is "virtually" reshaped to be compatible with another numpy array for a certain operation. Do not confused yourself about it with the broadcast concept in Spark which sends a full copy of a (small) DataFrame to each work node for
BroadCastJoin