Category Python Modules

Modules is one of the best feature of Python. Except some core modules, you can install what you need and keep your Python setup smooth.

cv2.imwrite: Save Images in Python

cv2.imwrite: Save Images in Python

Saving an image in Python starts with choosing a filename and destination. cv2.imwrite() encodes an image array using the filename extension and writes it to a file. This article shows how to save an array with cv2.imwrite() and where a…

Pandas to Excel: Export a DataFrame

Pandas to Excel: Export a DataFrame

Saving a pandas DataFrame as an Excel workbook starts with DataFrame.to_excel(). It writes the table to a worksheet, where you can choose a name and whether the row index appears. I’ll show how to export a single worksheet and write…

Pandas Read Excel: Load a Workbook

Pandas Read Excel: Load a Workbook

A Python analysis can start with the values stored in an Excel worksheet. pandas.read_excel() reads worksheet values into a DataFrame, a labeled table with rows and columns. I’ll show how to read one sheet or collect several, and how to…

Import Math Module in Python

Import Math Module in Python

For a circle-area calculation in Python, you can use pi from the math module. Python’s math module provides numeric constants and functions, including math.pi for circle calculations. This article shows how to import pi by name and choose a math…

Python sys Module: Arguments, Paths, and Streams

Python sys Module: Arguments, Paths, and Streams

Command-line arguments let a Python script receive values supplied when it starts. The sys module exposes those argument strings alongside information maintained by the running interpreter. I’ll show how to read sys.argv and check whether an optional argument is present…

np.outer(): Outer Product in NumPy

np.outer(): Outer Product in NumPy

To calculate every pairwise product between two inputs, use NumPy’s np.outer function. It multiplies each value in one input by each value in the other and returns a two-dimensional array. This article explains how the input shapes determine the result…

np.linalg.solve() Linear Systems

np.linalg.solve() Linear Systems

To solve a set of linear equations, find the values of its unknowns. NumPy’s np.linalg.solve() does that when the coefficient matrix has the same number of rows and columns and its equations are independent. I’ll show how to put the…