Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # def is_leap_and_29Feb(s):
- # Some ways to deal with leap years.
- # In reality, what we want to do is remove Feb29, but add the daily
- # return to the figure from the 28th - we shouldn't lose the data.
- # df.drop(df.index[['2012-02-29']])
- # df = df[~((df.index.month == 2) & (df.index.day == 29))]
- # df = df[~df.index.str.endswith('02-29')]
- # def _292(date): return (date.month==2) & (date.day==29)
- # df['DATE'][df['DATE'].apply(_292)]-=pd.Timedelta('1D') # yesterday
- # if calendar.isleap(year):
- # do_stuff
- # else:
- # do_other_stuff
- # mask = is_leap_and_29Feb(df)
- # print mask
- #[False False False False False True False False False True]
- # print df.loc[~mask]
- #return (s.index.year % 4 == 0) &
- # ((s.index.year % 100 != 0) | (s.index.year % 400 == 0)) &
- # (s.index.month == 2) & (s.index.day == 29)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement