[Tutor] clipping 2 arrays that are in a single cell in a dataframe
David Wolfe
dkwolfe at gmail.com
Wed Mar 4 08:49:22 EST 2020
So I have the following code and output
Input:
x = dq.iloc[0,1]
print(x)
Output:
(array([ 2.22103139e-16, 3.90537106e-16, 5.69543182e-16, ...,
-2.35780223e-08, -2.26280054e-08, -2.13661206e-08]), array([
7.68783923e-17, 1.43759013e-16, 2.15375256e-16, ...,
-1.06071943e-08, -1.02689930e-08, -9.77763418e-09]))
As you can see, the contents of this particular cell are 2 arrays.
The problem is that there is a lot of junk data in this data. The
array is actually X and Y coordinates, but none
of them should be below or less than 1. When I had just 1 array per
cell, I used the following to limit the array to just what I needed:
x_above_one_hundred = np.where(x>10Output:0)
xx = np.clip(x[x_above_one_hundred],125,300)
Now, I just need something to do the same thing when I have 2 arrays
in a dataframe cell.
Thanks,
David
More information about the Tutor
mailing list