Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

numpy

Efficiently sorting a numpy array in descending order?

August 12, 2022 by Magenaut

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.

Categories Python, Q&A Tags arrays, numpy, python, sorting Leave a comment

How do I pass large numpy arrays between python subprocesses without saving to disk?

August 12, 2022 by Magenaut

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:

Categories Python, Q&A Tags ctypes, numpy, pass-by-reference, python, subprocess Leave a comment

Simple wrapping of C code with cython

August 11, 2022 by Magenaut

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:

Categories Python, Q&A Tags cython, numpy, python Leave a comment

binning a dataframe in pandas in Python

August 11, 2022 by Magenaut

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

Categories Python, Q&A Tags numpy, pandas, python Leave a comment

Convert RGB to black OR white

August 11, 2022 by Magenaut

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).

Categories Python, Q&A Tags numpy, opencv, python, python-imaging-library Leave a comment

pandas equivalent of np.where

August 11, 2022 by Magenaut

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.

Categories Python, Q&A Tags numpy, pandas, python, where-clause Leave a comment

Map each list value to its corresponding percentile

August 11, 2022 by Magenaut

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.

Categories Python, Q&A Tags median, numpy, percentile, python, scipy Leave a comment

Annotate Time Series plot in Matplotlib

August 11, 2022 by Magenaut

I have an index array (x) of dates (datetime objects) and an array of actual values (y: bond prices). Doing (in iPython):

Categories Python, Q&A Tags matplotlib, numpy, python Leave a comment

How to convert list of numpy arrays into single numpy array?

August 11, 2022 by Magenaut

Suppose I have ;

Categories Python, Q&A Tags list, numpy, python Leave a comment

Python: find contour lines from matplotlib.pyplot.contour()

August 11, 2022 by Magenaut

I’m trying to find (but not draw!) contour lines for some data:

Categories Python, Q&A Tags contour, matplotlib, numpy, python, spatial Leave a comment
Older posts
Newer posts
← Previous Page1 … Page50 Page51 Page52 Page53 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress