samedi 7 mars 2020

Logical Operator Python two == does not work in iteration dataframe

I have a dataframe and would like to select two rows to interpolate between these with a self defined function. The proplem is that I only see one row and dont understand why my of statement is not working. The data looks like the following:

        DataPoint   Rank
1       -9.360001   1.0
2       -9.080002   2.0
3       -9.039993   3.0
4       -7.529999   4.0
5       -7.479996   5.0
...     ...     ...     ...     ...

I would like to interpolate e.g. between rank 2.0 and 3.0. The code looks like the following:

Rank = data[['DataPoint']].count().values[0]*(1-0.99)
check_int = isinstance(Rank, int)
if not check_int:
        #loop 
        for ind in data.index:
            if (data['DataPoint'][ind] == (2.0 and 3.0)):
                print(data['DataPoint'][ind], data['Rank'][ind])

As Output I only receive:

-9.03999300000001 3.0

but not in addition

-9.080002 2.0

Aucun commentaire:

Enregistrer un commentaire