How to Copy Files to Another Directory in Python

Copy files to another directory in Python: Command Prompt output of a script copying four photos into a delivery folder

A wedding photographer in Austin asked me to copy files to another directory in Python after every shoot: the JPEGs from her camera folder go into the client’s delivery folder, and an edited photo never gets overwritten. The answer is shutil.copy2(src, dest_folder) inside a loop, with an exists() check before each copy. It copies the … Read more >>

How to Check if a Directory Exists in Python

Check if a directory exists in Python: Command Prompt output of os.path.isdir on four sample paths

To check whether a folder is there, call os.path.isdir(path) or Path(path).is_dir(). Both return True only for an existing folder, never for a file. In this tutorial, I’ll show you four ways to check if a directory exists in Python, plus how to create the folder when it’s missing. Every result below comes from real runs … Read more >>

How to Calculate Standard Deviation in Python

How to calculate standard deviation in Python: NumPy std with ddof versus pandas std

Here’s how to calculate standard deviation in Python: for a plain list, use statistics.stdev() for a sample or statistics.pstdev() for a whole population. With arrays, use numpy.std(), but watch its default: I calculated everything below on Python 3.12.5, NumPy 2.5.3 and pandas 3.0.6 using a week of made-up store sales in USD. You’ll get the … Read more >>

Python chr() Function: Convert Integers to Characters

Python chr() function: Command Prompt output converting the integers 65, 97, 48 and 36 to A, a, 0 and $

The Python chr() function takes an integer Unicode code point and returns the one-character string it stands for. So chr(65) gives ‘A’, and chr(8364) gives the euro sign: It’s the reverse of ord(), and it accepts any whole number from 0 to 1,114,111. In this tutorial, I’ll cover the syntax, ASCII and Unicode examples, building … Read more >>

How to Write a Pandas DataFrame to Excel in Python

pandas write DataFrame to Excel: Q1 2026 sales workbook in Excel with USD formatting, a total row and a column chart

Every quarter, a sales manager I work with asks for the same thing: the numbers from my pandas script, but as a workbook she can open, filter and forward. That’s the job of a pandas write DataFrame to Excel step. Renaming a CSV to .xlsx doesn’t work; Excel warns that the format and extension don’t … Read more >>

Python NumPy Not Found: How to Fix No Module Named NumPy

Python NumPy not found: Command Prompt traceback ending in ModuleNotFoundError: No module named 'numpy'

Your script dies on line one with ModuleNotFoundError: No module named ‘numpy’. NumPy usually isn’t missing from your computer. It’s missing from the Python that’s running your code. Quick answer: a Python NumPy not found error means the interpreter running your script has no NumPy package. Install it into that same interpreter with python -m … Read more >>

How to Install Python on Mac (macOS) in 2026

Install Python on Mac: the python.org macOS downloads page with the latest Python 3 release

You can install Python on Mac OS X (now macOS) in a few minutes: download the macOS installer from python.org, run it, then type python3 –version in Terminal. Homebrew users can do it in one command instead: As of October 2026, python.org lists Python 3.14.8 as the latest release, and Homebrew’s python@3.14 formula is on … Read more >>

Breadth First Search in Python (BFS with Examples)

Breadth first search in Python: Command Prompt output of BFS solving a grid maze with the shortest path

Breadth first search in Python explores a graph level by level: first the start node, then all its neighbors, then their neighbors, and so on. You build it with a queue from collections.deque and a set of visited nodes: Every BFS here uses only the standard library, and I ran each one with Python 3.12.5 … Read more >>

R vs Python: Which Language Should You Learn in 2026?

R programming language vs Python: pandas groupby output compared with R dplyr

R vs Python comes down to focus. The R programming language was built by statisticians for statistics and charts, while Python is a general-purpose language that also happens to be excellent at data science. If you’re picking one, I’d start with Python. I’m not running R on this machine, so the R snippets are shown … Read more >>

How to Read an Excel File in Python

Python read Excel file: Command Prompt output of openpyxl reading sales rows from an xlsx workbook

To read an Excel file in Python, call pandas.read_excel(“file.xlsx”), which returns a DataFrame, or use openpyxl.load_workbook() when you need individual cells, formulas or formatting. Both read .xlsx files, and pandas uses openpyxl underneath: The workbook in these examples is a small 2026 sales report with a Stores sheet. I read it with Python 3.12.5, pandas … Read more >>