Skip to content

Tag: python

Trying to supply PGPASS to Docker Image

New to Docker here. I’m trying to create a basic Dockerfile where I run a python script that runs some queries in postgres through psycopg2. I currently have a pgpass file setup in my environment variables so that I can run these tools without supplying a password in the code. I’m trying to replic…

Compute row distance matrix using only for loops

I am stuck in trying to calculate a distance matrix from different binary arrays and I can only use for loops to resolve this… The problem consists of the following; Imagine I have a binary matrix built with different rows as follows, with dimension n=3,m=3 in this case: And I would like to achieve the …

Matplotlib – Delete lines from a 3d quiver plot

I would like to graphically represent the time trend of a three-dimensional reference frame using Matplotlib and the quiver function. In an event, I simulated the data representing the reference frame through the definition of a 3×3 rotation matrix. Each time the event occurs, it should delete the previo…

Reading csv file with partially variable name

I want to read a csv file into a data frame from a certain folder with pandas. This folder contains several csv files. They contain different information. The first part in the filename (1 – 8 is variable). I want to read it in the file which ends with ‘_Reference.csv’, but I have no clue ho…

How to test Docker container on another machine?

I wrote a simple script as follows: I dockerized it and put it in a container, and ran it from there. Everything is working fine. I have another machine with Linux OS. How can I test this container there? Do I need to simply copy paste it or what? Answer You need to install Docker on the other machine, and

Multiply xarray variables with a numpy array

I have an xarray.DataArray: and I want ro multiply each mode with an element of the array array([68.8005905 , 17.8959575 , 8.46729004]). Any idea how to do that? Answer This is exactly what xarray is intended to help with you’re on the right track! Unlike numpy, which relies on dimension order and posit…

Get number of Clusters (3D)

I have a question about clustering. When you’re using k-nearest neighbour algorithm, you have to say, how many clusters you’re expecting. My problem is now, that I have some runs, where the number of clusters varies. I checked, and there are some methods how you can restrict, how many clusters you…

Python – save multiple responses from multiple requests

I am pulling JSON data from an api and I am looking to pass in a different parameter for each request and save each response My current code I save a response and print out the values. This is fine and it works but I only store the first ID’s response. How do I store the responses from all of