Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. # def is_leap_and_29Feb(s):
  2. # Some ways to deal with leap years.
  3. # In reality, what we want to do is remove Feb29, but add the daily
  4. # return to the figure from the 28th - we shouldn't lose the data.
  5.  
  6. # df.drop(df.index[['2012-02-29']])
  7. # df = df[~((df.index.month == 2) & (df.index.day == 29))]
  8. # df = df[~df.index.str.endswith('02-29')]
  9. # def _292(date): return (date.month==2) & (date.day==29)
  10. # df['DATE'][df['DATE'].apply(_292)]-=pd.Timedelta('1D') # yesterday
  11. # if calendar.isleap(year):
  12. # do_stuff
  13. # else:
  14. # do_other_stuff
  15.  
  16. # mask = is_leap_and_29Feb(df)
  17. # print mask
  18. #[False False False False False True False False False True]
  19. # print df.loc[~mask]
  20. #return (s.index.year % 4 == 0) &
  21. # ((s.index.year % 100 != 0) | (s.index.year % 400 == 0)) &
  22. # (s.index.month == 2) & (s.index.day == 29)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement