Skip to content

Tag: numpy

Numpy rounding issue

Can someone explain to me why is numpy round acting strange with this exact number rounding: It’s obvious that the first number is not rounded well, any ideas? EDIT: Since I’m focused here on the precision, not so much on the performance, I’ve used python round function to solve this problem…

Remove specific rows that contain dates Python

I have a dataset that has datetime values in it. I would like to remove all rows within a specific column that contain a certain year. All rows that contain 2027 should be removed. Data Desired Doing Any suggestion is appreciated. Error: AttributeError: Can only use .str accessor with string values! I believe…

How to fill in missing center of a 2d gaussian

I have a 2d gaussian whose center has been destroyed by pixel saturation. I need the center to be filled in because a poorly filled in center will confuse a neural network I’m trying to train. See below: The scattered nan values I can handle fairly easily, but the large cluster in the gaussian’s c…

convert multiple units to KG in pandas

let’s say i have this code(which is obviously wrong) I want to apply such condition to each value in a column(weights) based on another column(weight unit). Is there an efficient way to do it. Preferably allowing a func pass so easy to modify Answer Don’t use a function, this will be slow. numpy.v…

Reordering a list based on another list in Python

I have two lists Ii0 and Iv0 containing numpy arrays. I am using argsort() to reorder elements in Ii0 to generate a new list Ii01. I want to use the same order to reorder elements in Iv0 to generate a new list Iv01. I present the current and expected output. The current output is The expected output is Answer…

Is there a way to resize a batch of images?

I am trying to make code of object detection efficient. I currently have multiple sources, Below is the pseudo code: Take images via cv2.imread() or cap.read() from all sources one by one. Pre-process them one by one: a. Resize b. Normalise Make batch. Pass to model. Post process one by one. Now, since images…