IIUC:
You want the ordinal positions of where the 'GDP'
values were greater than the last one and less then the next one.
Consider the dataframe df3
np.random.seed([3,1415])
df3 = pd.DataFrame(dict(GDP=np.random.randint(10, size=15)))
print(df3)
GDP
0 0
1 2
2 7
3 3
4 8
5 7
6 0
7 6
8 8
9 6
10 0
11 2
12 0
13 4
14 9
solution
using shift
g = df3.GDP
x = np.arange(len(g))[g.gt(g.shift()) & g.lt(g.shift(-1))]
print(x)
[ 1 7 13]
The answer to your actual question is that you can't assess the truth of a pd.DataFrame
or pd.Series
and that's exactly what you were trying to do with
if((df3.iloc[i]<df3.iloc[i-1]) & (df3.iloc[i+1]<df3.iloc[i])):