Skip to content

Tag: numpy

create a matrix from combinations with values

I have some combinations like Any idea on how I efficiently can create a four by four matrix with these 0,1 values from all these combinations? So the result will be something like: Answer Imagine if the “combinations” are stored in a file in the following format (or similar): Then you can do: Exa…

Pulling x-values of spline integer y-values?

I have the given sample data and interpolated spline: I would like to pull the x values that correspond to the integer y values of the spline, but am not sure how to do this. I assume I will be using np.where() and have tried (to no avail): Answer You could use the find_roots function from this post to find

3D numpy array threshold comparison

I’m trying to solve whether or not each element in a 3d numpy array fits within a certain threshold. Currently I have nested for loops that get the job done, but it’s really slow and I don’t have all day to wait for my code to run LOL. The input spec is a little bit weird so I haven’t …

How to quickly subset many dataframes?

I have 180 DataFrame objects, each one has 3130 rows and it’s about 300KB in memory. The index is a DatetimeIndex, business days from 2000-01-03 to 2011-12-31: I preprocess all the data taking advantage of numpy/pandas vectorization, then I have to loop through the dataframes day by day. To prevent the …