I’m looking for a function like range except that the step is a fraction of the previous number generated. So if the fraction was 99/100 the set of numbers might be something like this: 100, 99, 98.01… 0.001 Would this be more efficiently done with a for-loop and range-like function or with just a while-loop? The code I have so
Tag: numpy
How to vectorize a function with lists as argument?
I need help vectorizing a function in numpy. In Julia, I can do something like that: which returns It takes one sublist at a time from the iterables and expands nothing. In Python, I just can’t get to have a similar behaviour. I tried: but it returns: If I do: I get back: I tried with excluded parameter, but il
How to mark data as anomalies based on specific condition in each interval
I try to search for this problem many places and couldn’t find the right tools. I have a simple time series data, For any sequence of data that is = 1 and span over (for example 1000 time instances). I want to mark those as anomalies (true). Else they should be ignore (as false). How do I achieve this with
Getting the coordinates of elements in clusters without a loop in numpy
I have a 2D array, where I label clusters using the ndimage.label() function like this: I can get the element counts, the centroids or the bounding box of the labeled clusters. But I would like to also get the coordinates of each element in clusters. Something like this (the data structure doesn’t have to be like this, any data structure
Error in implementing autokeras timeseries model
I was trying to implement autokeras TimeSeriesForecaster on a serial dataset. The features and label of the dataset are respectively given below. df1_x = AutoML preparation The dataframe has no NaN values, the shape of the features dataframe is (7111, 8) i.e. a 2D dataframe. But the error came as following: Answer You need to provide validation data to the
Numpy array assignment along axis and index
I have a 3D volume and I modify slices along different axis. (np.take is equivalent of writing self.volume[idx], self.volume[:, idx] and self.volume[:, :, idx]) Finally, I want to assign a new slice in my volume along the axis : This is where I need some help. I can’t figure out a cleaner way of doing this assignment. (I would like
Numpy applying a time interval sequence to a multidimensional ndarray (such as coordinates)
EDIT: added prefix / suffix value to interval arrays to make them the same length as their corresponding data arrays, as per @user1319128 ‘s suggestion and indeed interp does the job. For sure his solution was workable and good. I just couldn’t see it because I was tired and stupid. I am sure this is a fairly mundane application, but
Having some problem to understand the x_bin in regplot of Seaborn
I used the seaborn.regplot to plot data, but not quite understand how the error bar in regplot was calculated. I have compared the results with the mean and standard deviation derived from mannual calculation. Here is my testing script. You can see the y and e from the two ways are different. I understand that the default x_ci or x_estimator
How do I join two column values in string with empty values and integer in pandas?
So, I have the following data frame. I want to combine the values from those two columns into one separated by an underscore. I don’t want to have underscores in column with nan values. So far I have tried this. But the result is unsatisfying. I don’t want the trailing underscore for column without number. And I don’t want to
Reflecting 4d symmetric data
I’ve found out that there is no example of how to reflect symmetric 4d data, which can be very useful when 3d simulations wants to be performed using a symmetric plane to reduce calculations(e.g. ANSYS, COMSOL, etc). This example shows a data file structure corresponding to a COMSOL simulation, which has the structure: X, Y, Z, Amplitude The model had