1
我有一個foll的數據框。形式:減少熊貓數據幀中閏年的列值
datetime JD YEAR
2000-01-01 1 2000
2000-01-02 2 2000
2000-01-03 3 2000
2000-01-04 4 2000
2000-01-05 5 2000
2000-01-06 6 2000
2000-01-07 7 2000
2000-01-08 8 2000
2000-01-09 9 2000
...
2010-12-31 365 2014
的JD值是儒略日即它開始於1在每年的1月1日(打算高達366閏年和365人)。我想從每個閏年的2月29日開始每天減少JD值1。 JD值不應在非閏年中更改。這是我現在正在做的:
def reduce_JD(row):
if calendar.isleap(row.YEAR) & row.JD > 59:
row.JD = row.JD - 1
return row
def remove_leap_JD(df):
# Reduce JD by 1 for each day following Feb 29th
df.apply(reduce_JD, axis=1)
return df
pdf = remove_leap_JD(pdf)
但是,我沒有看到閏年的JD值有任何變化。我做錯了什麼?
- 編輯: 日期時間是索引列