0
我有這樣的一個下面我怎麼能在Python中創建這些列
Date Price
2017-01-01 100
2017-01-02 187
2017-01-03 183
我如何可以創建得到像
Date Price Previous_Days_Price
2017-01-01 100 NaN
2017-01-02 187 100
2017-01-03 183 187
我有這樣的一個下面我怎麼能在Python中創建這些列
Date Price
2017-01-01 100
2017-01-02 187
2017-01-03 183
我如何可以創建得到像
Date Price Previous_Days_Price
2017-01-01 100 NaN
2017-01-02 187 100
2017-01-03 183 187
pandas.Series.shift
前幾天的信息列中的數據集就是你想要...
df['Price'].shift(1)
可能有些日期不見了,例如'2017-01-01','2017-01-03','2017-01-04','2017-01-06', '2017年1月7日'? – jezrael