This is my first time asking a question on here, so apologies if I am doing something wrong. I am looking to create some sort of dataframe/dict/list where I can check if the ID in one column has seen a specific value in another column before. For example for one pandas dataframe like this (90 ..

#### Category : numpy

I am trying to compute the transition matrix from time-series data. I wrote a custom function like the following code that serves my purpose. def compute_transition_matrix(data, n, step = 1): P = np.zeros((n, n)) m = len(data) for i in range(m): initial, final = i, i + step if final < m: P[data[initial]][data[final]] += 1 ..

I have an array A with shape (N,). I am taking N=5 for illustration: A = np.array([0,1,1,0,1]) And I want to transform it to one of the following two NxN matrices. The more efficient solution is preferred. Numpy and Tensorflow are both good. B = np.array([[0,1,1,0,1], [0,1,1,0,1], [0,1,1,0,1], [0,0,0,0,1], [0,0,0,0,1]]) C = np.array([[0,0,0,0,0], [0,1,0,0,0], [0,1,1,0,0], ..

I am developing my own Architecture Search algorithm using Pythons numpy. Currently I am trying to determine how to develop a cost function that can see the distance between X and Y, or two matrices. I’d like to reduce the difference between the two, to a meaningful scalar value. Ideally between 0 and 1, so ..

I’m new to python and I’m trying to follow a tutorial on object detection, but my code calling find (which calls cv.matchTemplate) this error: import cv2 as cv import numpy as np from time import time from random import randint from windowcapture import WindowCapture from vision import Vision #points = get_click_points(‘img2.jpg’, ‘copper.jpg’, threshold=0.55, debug_mode=True) wincap ..

I have to convert a pandas Series to NumPy array of dtype=float64, this is the code that raises the error: series = pd.Series( [np.random.randn(5), np.random.randn(5), np.random.randn(5), np.random.randn(5)]) res = series.to_numpy() res.astype(np.float64) This is the error I got: —-> 3 res.astype(np.float64) ValueError: setting an array element with a sequence. I want to understand why this raises ..

I have written a function to get a sequence for LSTM/GRU sequence model based on group ID. I am not getting expected output. Python Function: def windowGeneratorByID(data, target, id_col_index, lookback, offset, batch_size=16): min_index=0 max_index = data.shape[0]-offset i = min_index + lookback while 1: if i + batch_size >= max_index: i = min_index + lookback rows ..

I have a working R code to slice rows based on modulus condition, I am trying to achieve same thing in python Any help will be really appreciated. R Code: data = read.table(text = ‘id a b 1 2 0 1 3 0 1 0 0 1 0 1 2 1 0 2 1 1 ..

I am trying to take understand the frequencies of a dataset and am having issues in getting the fast Fourier transform to work. The main problem is that I cannot figure out how to get the correct frequencies on the x-axis. Background I have a dataset with many columns but the columns of interest are ..

Very new to python so apologies for the inelegance of code I have a numpy array with two subarrays: import numpy as np p = 0.50 gen_seq = np.random.binomial(1, p, 20).reshape(2, 10) t_form = np.where(gen_seq == 1, 0.5, -100) initial_w = np.insert(t_form, 0, 100, axis=1) d_account = np.cumsum(initial_w, axis=1) I am trying to find the ..

## Recent Comments