Skip to content Skip to sidebar Skip to footer

Very Slow Numpy Or Operation

I am doing an OR operation on large dataset which is an numpy dtype array object. Below code is part of outer FOR loop which goes through 15 columns and check if username is availa

Solution 1:

alist = [(np_array[:,col_index[f"COL_{col_number}"]] == username) for col_number in range(columns)]

this should be a list of all the col_number tests

mask = np.logical_or.reduce(alist)

should or them together. Performance should be better than repeatedly oring. But I wouldn't surprised if the alist construction is the slowest step.

But without a working example, I can't test or time this.

Post a Comment for "Very Slow Numpy Or Operation"