Hier ist mein Datensatz mit Index als Daten und Preis Spalte. Ich möchte hier eine Spalte Parameter (param) erstellen, die wie in der Kommentarspalte folgt:Berechnen High Low in Pandas
Index Price | param Comments (P is Price)
1989-01-24 68.800 0 P < P-1 (P-1 doesnt exist so 0)
param = 0 ,
1989-01-25 68.620 -2 P < P-1 check P<P-2(P-2 doesnt
exist so P is a 2 day low and
param = -2
1989-01-26 68.930 3 P > P-1, P>P-2, P-3(doesnt exist
So P is a 3 day high, param =3
1989-01-27 68.9900 4 P > P-1 > P-2 > P -3 and hence a
4 day high, param = 4
1989-01-30 69.11 5 P > P-1> P-2 > P-3 > P-4 and
hence a 5 day high, param = 5
1989-01-31 69.070 -2 P < P-1 > P-2 and hence a 2 day
low, param = -2
Kann jemand bitte sagen Sie mir eine elegante Möglichkeit, dies in Pandas zu erreichen?
Was ist die Grundlage für die Bildung der 'Param'-Spalte? – CodeHunter
@piRSquared können Sie mir helfen? – Wolverine