Skip to content
Home » python » Page 2

python

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

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… 

Python: execute shell commands (and get the output) with the os package

Running shell (e.g. Bash) commands in Python is fairly easy using the os package. In this article, I outline two ways to run shell commands in Python: using the system method and the popen method. This article is part of a two-part series related to running shell commands from within… 

Fix “Source url of disk is missing” when attaching disk to instance in GCP using Python

  • by
  • 2 min read

I would like to briefly elaborate on an error I ran into, which is due to limited documentation on the Google Cloud Platform API. With this article, I hope to save you the time and effort to find the solution. I’ve been following an infrastructure-as-code approach to deploying GCP resources…