jeudi 26 octobre 2017

List comprehension if and - ignoring the second condition

I've found a similar post here but without the context I'm struggling to understand it.

I have a pd.dataframe holding the results from pairwise adf tests. I'd like to make a filter to return only the rows where the adf statistic is less than the 1% critical value AND where p is less than 0.05.

pvalue = 0.05

print([str(row) for row in adfstats.itertuples() if (float(row.adf) <= float(row.critvalues['1%']) and float(row.p) < pvalue)])

This seems to return the rows with adf below the 1% critical value but disregards the pvalue argument. I've been fiddling with this for hours (literally) to no avail so suggestions are, as always, appreciated.

Aucun commentaire:

Enregistrer un commentaire