import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('Area_-116_32.txt', usecols = 2)
plt.hist(data, bins=40, range=[2.6,5], log=10)
e= np.array(data)
condition = np.mod(e)>2.6 and np.mod(e)<5
this gives an error of
TypeError Traceback (most recent call last) Input In [34], in <cell line: 1>() ----> 1 condition = np.mod(e)>2.6 and np.mod(e)<5
TypeError: remainder() takes from 2 to 3 positional arguments but 1 were given
CodePudding user response:
numpy.clip(a, a_min, a_max, out=None, **kwargs
Edit if you want to remove those values from the array instead of clipping them, you just need to re-make your array:
>>> x=np.array([3, 6, 7, -2, -5, -1, -1, 3, 1, -1, -2, -1, -5, -1])
>>> x[(x>-2) & (x<6)]
array([ 3, -1, -1, 3, 1, -1, -1, -1])