Reputation: 197
Here's the thing, I have two arrays. One is a list of names and the other are values. I want to put them together and filter all names where the values are higher than zero.
How can I do this?
Something like this, the array is the list of coefficients from a regression, just like this:
array([-0.1, 0.82105695, 0, 0, 10])
The list is the name of the columns:
Index(['col1', 'col2', 'col3', 'col4', 'col5'],
dtype='object', length=1000)
I want the result to be the list of columns with values higher than 0. Is there an easy way of doing this?
Upvotes: 1
Views: 17
Reputation: 111
Try to make a for
loop that is the same length of the values list, and then check if the value is higher then zero. If the value is higher then zero use .remove()
or .pop()
in order to delete the name of the column from the columns list.
(I hope I understand your question...)
Something like this:
for i in len(values_array):
if values_array[i-1] > 0:
columns_array.pop(i-1)
Upvotes: 1