Python

glob

The glob module finds all the pathnames matching a specified pattern according to the rules used by the Unix shell. If you need a list of filenames that all have a certain extension, prefix, or any common string in the middle, use glob instead of writing code to scan the directory contents yourself.

2020-12-25

YAML in Python

YAML YAML = YAML Ain’t Markup Language Human-readable data-serialization language It is commonly used for configuration files, but it is also used in data storage (e.g. debugging output) or transmission (e.

2020-12-09

JSON

TL;DR Python and JSON conversion JSON (JavaScript Object Notation) is a popular data format used for representing structured data. It’s common to transmit and receive data between a server and web application in JSON format.

2020-12-09

Numpy Random

Common used functions import numpy as np We use numpy.random package to generate an array of random values instead of looping through the random generation of one variable. np.random.randn() Return a sample (or samples) from the “standard normal” distribution.

2020-11-23

Numpy Tile

x = np.array([[1, 2], [3, 4]]) print(x) print(x.shape) [[1 2] [3 4]] (2, 2) x1 = np.tile(x, (1, 2)) print(x1) print(x1.shape) [[1 2 1 2] [3 4 3 4]] (2, 4) Numpy tile Reference numpy tile documentation

2020-11-22

File I/O

What is a File? At its core, a file is a contiguous set of bytes used to store data. This data is organized in a specific format and can be anything as simple as a text file or as complicated as a program executable.

2020-11-19

Working with Files

with open(...) as ... pattern open() opens file for reading or writing and returns a file handle Use appropriate methods to read or write this file handel Example Read with open('data.

2020-11-19

IPython and Shell Commands

Shell Commands in IPython Any command that works at the command-line can be used in IPython by prefixing it with the ! character. Example ! echo 'hello world!' # echo is like Python's print function hello world!

2020-11-07

Modules and Packages

Modular programming refers to the process of breaking a large, unwieldy programming task into separate, smaller, more manageable subtasks or modules. Individual modules can then be cobbled together like building blocks to create a larger application.

2020-10-29

f-string

Python f-string is the newest Python syntax to do string formatting. Python f-strings provide a faster, more readable, more concise, and less error prone way of formatting strings in Python. đź‘Ź

2020-10-21