Skip to content
Advertisement

Tag: numpy

applying .astype() for specific indices doesn’t work

I want to change first column to int in dnarray [[ 1. 6.218 2.974 0. ] [ 2. 32.881 8.66 0. ] [ 3. 38.94 35.843 0. ] [ 4. 8.52 35.679 0. ] [ 5. 52.902 49.538 0. ]] float64 int32 float64 I tried to use deepcopy, but no success. Any help will be good, I didn’t find any

Map pandas dataframe columns to an array

I have a dataframe like this: And an array like: The first element will be for family_id=0 and column “choice_0” = 52 The second element will be for family_id=1 and column “choice_2” = 82 The third element will be for family_id=2 and column “choice_4” = 27 And I will like to get: The logic will be: For family_id =0 The

Pandas: Remove Column Based on Threshold Criteria

I have to solve this problem: Objective: Drops columns most of whose rows missing Inputs: 1. Dataframe df: Pandas dataframe 2. threshold: Determines which columns will be dropped. If threshold is .9, the columns with 90% missing value will be dropped Outputs: 1. Dataframe df with dropped columns (if no columns are dropped, you will return the same dataframe) Excel

Finding the minimum of the N numpy matrices?

I want to find the minimum of N numpy matrices elementwise (but with a twist, read till the end). To show, I create 3 numpy matrices as follows: I except my output d to be: I also need to retain the information from where does the each element in the d matrix is coming from. So if I label a,

Is there a fast way to shuffle numpy image in segments?

I want to write a function that can take small images and return a permutation of them, block-wise. Basically I want to turn this: Into this: There was an excellent answer in Is there a function in Python that shuffle data by data blocks? that helped me write a solution. However for ~50,000 28×28 images this takes a long time

Advertisement