Ich habe Pandas Datenrahmen mit Datum eine Spalte, ich möchte eine neue Spalte mit vorherigen Datumsindex im Datenrahmen hinzufügen. Wie erreiche ich das? Probe df:Pandas erhalten Index des vorherigen Datums
index Date
0 2015-10-03
1 2015-11-03
2 2015-11-30
3 2015-11-30
4 2015-12-03
gewünschte Ausgabe:
index Date previous_day
0 2015-10-03 0
1 2015-11-03 0
2 2015-11-30 1
3 2015-11-30 1
4 2015-12-03 3
- Da bei Index 1 kein Vortages ist möchte ich 1 in Vortages.
- Seit Datum bei Index 2 ist die gleiche wie Index 3 I 1 in previous_day für Index erwarten 3.
Danke,
Datum bei Index 2 ist nicht identisch mit Index 3! – harshil9968
@ harshil9968 Datum bei Index 2 (2015-11-30) ist das gleiche wie Datum bei Index 3 (2015-11-30) – nilesh