Posts tagged "python"
8 posts
Demonstrating handling Python errors with reproducible scripts
This article demonstrates how to enhance Python error handling using the traceback module while leveraging uv's support for PEP 723 to create reproducible scripts. It provides practical examples of how to move beyond basic ValueError implementations to include stack traces in error messages, making debugging and error handling more informative in production environments.
Quickly checking Python dependencies
A short snippet for using `uv` to iterate on changing Python project dependencies.
LLMs on the command line
I've integrated Large Language Models (LLMs) into my workflows to automate developer activities. This improves my understanding of their capabilities. I provide practical use cases, including code review, file summarization, web page content extraction, and even analyzing running processes, illustrating the diverse applications of LLMs in my daily tasks.
How to Safely Upsert DataFrames into Postgres
I share a Python script that safely upserts Pandas DataFrames into a Postgres database using psycopg2, highlighting the importance of handling potential SQL injection risks. I explain the process of constructing SQL statements to manage inserts and updates based on specified constraints, while utilizing the `execute_batch` function for efficient batch processing.
Classifying data with Python
Using scikit-learn and some Python features to set up a machine learning pipeline to quantify the efficiency of different classifers for classifying the movement of a stock price.
Calculating covariance matrices with Python
I wanted to use lower level linear algebra constructs in Python to calculate a covariance matrix.
How to reduce the memory used by Pandas DataFrames
A script illustrating how the memory usage of a pandas DataFrame can be reduced through altering data types.
Reconstructing a point set from a Euclidean Distance Matrix
Recovering point locations from vectors.