mercredi 5 août 2020

How can I get list values that meet specific conditions?

I'm an introductory member of Python. I are implementing code to organize data with Python. I have to extract a value that meets only certain conditions out of the numerous lists. It seems very simple, but it feels too difficult for me.

First, let me explain with the simplest example

solutions
Out[73]: 
array([[ 2.31350622e-04, -1.42539948e-02, -7.17361833e-02,
         2.17545418e-01, -3.38251827e-01,  1.88254191e-01],
       [ 4.23523963e-82, -9.48255372e-81,  5.22018863e-80,
        -1.11271010e-79,  1.03507672e-79, -3.55573390e-80],
       [ 2.31350597e-04, -1.42539951e-02, -7.17361800e-02,
         2.17545409e-01, -3.38251817e-01,  1.88254187e-01],
       [ 2.58309722e-02, -6.21550000e-01,  3.41867505e+00,
        -7.53828444e+00,  7.09091365e+00, -2.39409614e+00],
       [ 2.31350606e-04, -1.42539950e-02, -7.17361809e-02,
         2.17545411e-01, -3.38251820e-01,  1.88254188e-01],
       [ 1.14525725e-02, -3.25174709e-01,  2.11632584e+00,
        -5.16113713e+00,  5.12508331e+00, -1.78380602e+00],
       [ 9.75839726e-03, -3.08729919e-01,  2.26983591e+00,
        -6.16462170e+00,  6.76409438e+00, -2.55992476e+00],
       [ 1.13190092e-03, -6.72042220e-02,  7.10413638e-01,
        -2.39952623e+00,  2.94849402e+00, -1.18046338e+00],
       [ 5.24406689e-03, -1.86240596e-01,  1.36500589e+00,
        -3.61106144e+00,  3.75606312e+00, -1.34699295e+00]])

coeff
Out[74]: 
array([[ 1.03177808e-04, -6.35700011e-03, -3.19929208e-02,
         9.70209594e-02, -1.50853634e-01,  8.39576506e-02,
         4.45980248e-01],
       [ 5.13911499e-83, -1.15062991e-81,  6.33426960e-81,
        -1.35018220e-80,  1.25598048e-80, -4.31459067e-81,
         1.21341776e-01],
       [ 1.03177797e-04, -6.35700027e-03, -3.19929194e-02,
         9.70209556e-02, -1.50853630e-01,  8.39576490e-02,
         4.45980249e-01],
       [ 4.26209161e-03, -1.02555298e-01,  5.64078896e-01,
        -1.24381145e+00,  1.16999559e+00, -3.95024121e-01,
         1.64999272e-01],
       [ 1.03177801e-04, -6.35700023e-03, -3.19929198e-02,
         9.70209566e-02, -1.50853631e-01,  8.39576495e-02,
         4.45980248e-01],
       [ 2.27512838e-03, -6.45980810e-02,  4.20421959e-01,
        -1.02529362e+00,  1.01813129e+00, -3.54364724e-01,
         1.98656535e-01],
       [ 1.42058482e-03, -4.49435521e-02,  3.30432790e-01,
        -8.97418681e-01,  9.84687293e-01, -3.72662657e-01,
         1.45575629e-01],
       [ 2.46722650e-04, -1.46486353e-02,  1.54850246e-01,
        -5.23029411e-01,  6.42688990e-01, -2.57307904e-01,
         2.17971950e-01],
       [ 1.30617191e-03, -4.63880878e-02,  3.39990392e-01,
        -8.99429225e-01,  9.35545685e-01, -3.35503798e-01,
         2.49076135e-01]])

In a matrix defined as 'numpy', called 'solutions', each row represents 'solutions[0]','solutions[1]', 'solutions[i]'... In addition, the 'coeff' is also defined as 'numpy', and the 'coeff[0]','coeff[1]','coeff[i]'... is matched to 'solutions[0]','solutions[1]','solutions[i]'...

What I want at this time is to find specific 'solution[i]' and 'coeff[i]' where all elements of solutions[i] are less than 10^-10 and all elements of coeff[i] are greater than 10^-3.

I wonder if there is an appropriate code to extract a list array in a situation that meets more than one condition. I'm a Python initiator, so please excuse me.

Aucun commentaire:

Enregistrer un commentaire