Questions tagged [linspace]

56 questions
0
votes
1 answer

In pandas: Interpolate between two rows such that the sum of interpolated values is equal to the second row

I am looking for a way to interpolate between two values (A and G) such that the sum of the interpolated values is equal to the second value (G), preferably while the distances between the interpolated values are linear/equally-sized. What I got…
MichlF
  • 139
  • 1
  • 8
0
votes
1 answer

How do I feed arrays into a linspace function in C++?

Disclaimer: this stuff is not my specialty. I am trying to feed 2 different 3 column 1 row arrays into a linspace function using the NumCPP package, but i'm getting errors such as: "no instance of function template "nc::linspace" matches the…
0
votes
1 answer

ValueError : Cannot setitem on a Categorical with a new category, set the categories first

I have a column with the values changing from 0 to 600 and I want to group that values from 0 to 9.2 by 0.4 increments and 1 group between 9.2 and 600 values as outlier.I tried the following code ; bin_labels = ['0-0.4', '0.4-0.8', '0.8-1.2',…
Ugur Selim Ozen
  • 159
  • 3
  • 10
0
votes
3 answers

How to append to a Numpy array using a for-loop

I'm trying to learn how to work with Numpy arrays in python and working on a task where the goal is to append certain values from a square function to an np array. To be specific, trying to append to the array in such a way that the result looks…
0
votes
0 answers

How to generate a Z value for a contour plot based on the x and y values

I am attempted to generate the Z values for a contour plot x = np.linspace(s_T,e_T,num=graph_density) y = np.linspace(s_P,e_P,num=graph_density) x,y = np.meshgrid(x,y) I have generated an x,y mesh grid to make up my x and y values of the plot. But…
Joe Wilson
  • 21
  • 4
0
votes
1 answer

Create "denser" np.linspace with same points as original np.linspace

I have a base array of equally spaced values [0, 1, ..., 511]. I need to create a target array over [0 to 511] that consists of approximately 4096 values. It must also contain all the values 0, 1, 2, ... that are in base. base = [0, 1, 2, 3, ...,…
0
votes
1 answer

Can I insert a '0' in `np.linspace`?

Suppose I have this equally spaced 'darray': epslist = np.linspace(-0.1,0.1,12) Is there a way I can 'insert' a '0' in this 'darray' with the 'ordered' position? By that, in this case, '0' should be added to the middle of epslist, instead of in the…
ZR-
  • 809
  • 1
  • 4
  • 12
0
votes
1 answer

Trying to using linspace in DataFrame but I am unable to get the output in correct format

import pandas as pd import numpy as np df = pd.DataFrame({'Number':[np.linspace(0,10,11,dtype=int)],'Year':[np.linspace(2000,2010,11,dtype=int)],'Person':[np.linspace(10,20,11,dtype=int)],'Age':[np.linspace(30,40,11,dtype=int)]}) df
0
votes
2 answers

How to use numpy linspace on multiple lines in dataset

Hello I need to use linspace to create points between two rows at a time in a dataset. 'location' 1 10 12 14 Essentially use linspace to find points between rows 1 & 2(1,10), then 3 & 4(12,14) (...for hundreds of rows). Any advice would be…
0
votes
1 answer

Numpy linspace function stop value

I giving start and stop values as parameters to the linspace function Stop value is normally does not include in the array. Because of this we always write [stop+1] in order to make include the stop value. But in linspace, if i write np.linspace(0,…
erenoz
  • 15
  • 1
  • 3
0
votes
1 answer

Generate a matrix(double) through colon operator in MATLAB and store it in cell

From the following code, I want to generate a matrix from the colon operator through a for-loop and have starting and ending values given in ends(20x2 double) where 1st and 2nd column of ends is the starting and ending values respectively. for…
0
votes
1 answer

np.linspace in if statement python

hey here's my code (I know there details to work yet), but I have a main problem so far, I want that depending on 2 inputs (u and horario_emision) the variable 'estabilidad_atm' gets a new value, it works when the first input is not in the…
0
votes
1 answer

How am I able to create bins that follow the shape of the gaussian function?

I am very new to coding, and I am trying to create a bell curve Gaussian that creates bars with the bin width 10 and quantity 30. Here us the code I am currently using. import numpy as np from matplotlib import pyplot as plt from scipy.stats…
0
votes
1 answer

Using numpy.linspace() method for a simpleaudio project, I get a typeError when I change the duration to a float. How do I work around this problem?

"""Here is the exact code from the simpleaudio docs which produces the error TypeError: object of type cannot be safely interpreted as an integer. The problem is T = 0.25. Everything works fine as long as T is an integer, however I require the…
nomadj
  • 31
  • 5
0
votes
0 answers

Error using numpy.linspace() in jupyter, Python 3.x

Using Python 3.x in Jupyter Notebook After importing pandas as pd and numpy as np I have a df dataframe, which has a "Price" column, I want to use np.linspace() as follows: bins = np.linspace(min(df["Price"]), max(df["Price"]), 3) and i get the…
app
  • 21
  • 1