Skip to content
Home » how to » Page 2

how to

Solve TypeError: ‘dict’ object does not support indexing when running SQL queries in Python

I ran into another silly error, for which I wanted to share the solution in order to save you some time. It occurs when trying to run a query using Python’s SQLAlchemy libary. Let’s dive right in. The problem When you’re trying to run a query, either by using Pandas’… 

How to copy the first value of a group to all rows in the group of a Pandas DataFrame

  • by
  • 2 min read

Recently, I needed to calculate the relative change of a value compared to the first value within a DataFrame group, a GroupBy object. With SQL, I would use a window function (e.g. PARTITION BY in PostgreSQL). In this article, we’ll do it in Pandas (Python). To demonstrate, let’s start with… 

How to generate random strings in Terraform

I’ve been working with Terraform recently for deploying the required architecture for a data pipeline in Google Cloud Platform (GCP). It’s my first project with Terraform and I decided to dive into its random_something resources, because I couldn’t have duplicate resource names. Here are some findings. Randomize a resource name…