Category "numpy"

Numpy array multiplies a constant and passed to cosine fucntion shows abnormal values

I want to lower the frequency of a cosine function with 100 times: import numpy as np import math import matplotlib.pyplot as plt x = np.arange(0, 100, 0.1) y

Replacing a value in a column with a value from the same column based upon information

I am looking for a way to do Missing value imputation. There is a table of entries over a given time, with an entry per hour done on days. There is a seperate

Matlab System Function and Terminal Runs differently

I have a python code that I want to run in Matlab. It has an `import NumPy statement in it. The code runs without a problem in the terminal. But when I use Matl

remove all rows including words (character) in numpy 2d array python

How can I remore words in my 2d array: from: array([['111', 'ACTG1'], ['131', '124'], ['95', '123'], ['95', '124'], ['95', 'ACTG1'],

Why does column + column concatenation create arrays for some Windows accounts?

When running the below Python code, I get different results depending on the user account/admin privileges that is used. The code is saved as test.py on a Windo

Python - Conditional 2D Permutation

Question: How might it be possible to calculate the permutations on a 2D array, but such that the sum of the indicies cannot exceed a certain number? E.g: maxsu

Applying a gradient map from image to another image with transparency in Python (PIL, numpy, etc)

I've been struggling with trying to apply a gradient map which is sourced from an image file to a grayscale image which includes alpha/transparency. The followi

Python: round(random.uniform) printing wrong float value on output console but in background its correct value

See the following code import re import random s = "~|21|050000|voltage|current|ApparentPower|12345~" for _ in range(100): vol_val = round(random.uniform(23

view of a NumPy array with non uniform stride

I have 1D array of N elements. I need to create a PxR view (where PxR<N) on this array according to strides that re not uniform but rather specified in a aux

Avoid interpolating over constraints

Hi I am in the process of interpolating data, but the data from N. America, for example, affect the data from Europe (see figure). I have found out that I must

reading data-frame with missing values

I am trying to read some df with few columns and few rows where in some rows data are missing. For example df looks like this, also elements of the df are separ

Fastest add with repeated indices: np.add.at / sparse.csr_matrix?

Say I have a num_indices * n indices matrix (in range(m)) and a num_indices * n values matrix, i.e., m, n = 100, 50 num_indices = 100000 indices = np.random.ran

How to fix the plot using iteration through the subplots?

import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv("population.csv") fig, axs = plt.subplots(nrows=2, ncols=2) for col, ax in zip(df.column

NumPy Slicing HackerRank

I have wrote a function named array_slice which gets four numbers n, n_dim, n_row, n_col from the user and performs array operations given below. Instructions:

What is the problem in this keras input shape?

from matplotlib import units import numpy as np from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras

Convert list of objects to numpy array without coercing objects into array

I want to turn a Python list of objects into a numpy array of objects for easier manipulation of the list, e.g. index slicing, etc. However, numpy coerces list-

Generate multiple new pandas dataframes using lists and for loops

I have the following dataframe: import pandas as pd import numpy as np from numpy import rec, nan df1=pd.DataFrame.from_records(rec.array([(202001L, 2020L, 'app

RankWarning: Polyfit may be poorly conditioned

I am trying to find the rolling price slope of btc trading data (minute data) using pandas. When I run the script, the following error / warning pops up sys:1:

RankWarning: Polyfit may be poorly conditioned

I am trying to find the rolling price slope of btc trading data (minute data) using pandas. When I run the script, the following error / warning pops up sys:1:

Using multi character delimiter while exporting SQL table as text file using python

I am trying to export SQL table as multi-character delimited text file in python. I have tried using Pandas, but it is only supporting single character as delim