Skip to content

Tag: python

How to prevent np.where from turning 0 into ‘0’?

I want to create an array with np.where that has strings and 0s in it. So usually its dtype would be ‘object’. Minimal example: As a result I get I would like those ‘0’s to be 0s. Since np.where has no argument for dtype, I don’t know how to do this except by replacing them after…

how to divide a column element wise in python

I want to divide the first column of this table element wise by 3.6. enter image description here It throws an error something like : Here’s what I tried: Answer There are several ways to do it, here are two. I suggest from your error message that your data is in a pd.DataFrame. I used a shortened versi…