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.

np.linalg.eig: Eigenvalues and Eigenvectors

np.linalg.eig: Eigenvalues and Eigenvectors

A square matrix can be analyzed by finding its eigenvalues and eigenvectors. NumPy’s np.linalg.eig returns the eigenvalues and right eigenvectors, with each vector in the column matched to its value by index. This article shows how to compute eigenpairs with…

How to Use np.sin() in NumPy

np.sin() in NumPy: Radians, Arrays, and Examples

A NumPy calculation may need the sine of one angle or a whole set of angles. The np.sin() function computes sine from radian inputs and applies the calculation element by element to arrays. This article shows how to calculate sine…

cv2.imread: Load Images with OpenCV

cv2.imread: Load Images with OpenCV

A Python script that works with image pixels needs to load the image first. OpenCV’s cv2.imread decodes an image file into a NumPy array for processing. You’ll see how to check whether decoding succeeded and how read modes affect the…

getpass Python: Hide Password Input

getpass Python: Hide Password Input

Writing a Python program that asks for a password calls for a prompt that does not display ordinary typing. Python’s built-in getpass module reads the password while hiding its characters in a supported terminal. This article shows how to call…

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…