Skip to content

Magenaut

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

numpy

Find column name in pandas that matches an array

August 18, 2022 by Magenaut

I have a large dataframe (5000 x 12039) and I want to get the column name that matches a numpy array.

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

Replacing Numpy elements if condition is met

August 18, 2022 by Magenaut

I have a large numpy array that I need to manipulate so that each element is changed to either a 1 or 0 if a condition is met (will be used as a pixel mask later). There are about 8 million elements in the array and my current method takes too long for the reduction pipeline:

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

How to copy a 2D array into a 3rd dimension, N times?

August 18, 2022 by Magenaut

I’d like to copy a numpy 2D array into a third dimension. For example, given the 2D numpy array:

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

Histogram Matplotlib

August 18, 2022 by Magenaut

So I have a little problem. I have a data set in scipy that is already in the histogram format, so I have the center of the bins and the number of events per bin. How can I now plot is as a histogram. I tried just doing

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

Consistently create same random numpy array

August 18, 2022 by Magenaut

I am waiting for another developer to finish a piece of code that will return an np array of shape (100,2000) with values of either -1,0, or 1.

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

How to get value counts for multiple columns at once in Pandas DataFrame?

August 18, 2022 by Magenaut

Given a Pandas DataFrame that has multiple columns with categorical values (0 or 1), is it possible to conveniently get the value_counts for every column at the same time?

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

Problems with pip install numpy – RuntimeError: Broken toolchain: cannot link a simple C program

August 18, 2022 by Magenaut

I’m trying to install numpy (and scipy and matplotlib) into a virturalenv.

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

What’s the fastest way in Python to calculate cosine similarity given sparse matrix data?

August 18, 2022 by Magenaut

Given a sparse matrix listing, what’s the best way to calculate the cosine similarity between each of the columns (or rows) in the matrix? I would rather not iterate n-choose-two times.

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

How does condensed distance matrix work? (pdist)

August 18, 2022 by Magenaut

scipy.spatial.distance.pdist returns a condensed distance matrix. From the documentation:

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

Coalesce values from 2 columns into a single column in a pandas dataframe

August 18, 2022 by Magenaut

I’m looking for a method that behaves similarly to coalesce in T-SQL. I have 2 columns (column A and B) that are sparsely populated in a pandas dataframe. I’d like to create a new column using the following rules:

Categories Python, Q&A Tags dataframe, numpy, pandas, python Leave a comment
Older posts
Newer posts
← Previous Page1 … Page16 Page17 Page18 … 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