Efficiently sorting a numpy array in descending order?
I am surprised this specific question hasn’t been asked before, but I really didn’t find it on SO nor on the documentation of np.sort.
I am surprised this specific question hasn’t been asked before, but I really didn’t find it on SO nor on the documentation of np.sort.
Is there a good way to pass a large chunk of data between two python subprocesses without using the disk? Here’s a cartoon example of what I’m hoping to accomplish:
I have a number of C functions, and I would like to call them from python. cython seems to be the way to go, but I can’t really find an example of how exactly this is done. My C function looks like this:
Given the following dataframe in pandas: import numpy as np df = pandas.DataFrame({"a": np.random.random(100), "b": np.random.random(100), "id": np.arange(100)}) where id is an id for each point consisting of an a and b value, how can I bin a and b into a specified set of bins (so that I can then take the median/average value … Read more
How would I take an RGB image in Python and convert it to black and white? Not grayscale, I want each pixel to be either fully black (0, 0, 0) or fully white (255, 255, 255).
np.where has the semantics of a vectorized if/else (similar to Apache Spark’s when/otherwise DataFrame method). I know that I can use np.where on pandas.Series, but pandas often defines its own API to use instead of raw numpy functions, which is usually more convenient with pd.Series/pd.DataFrame.
I’d like to create a function that takes a (sorted) list as its argument and outputs a list containing each element’s corresponding percentile.
I have an index array (x) of dates (datetime objects) and an array of actual values (y: bond prices). Doing (in iPython):
Suppose I have ;
I’m trying to find (but not draw!) contour lines for some data: