Every line of 'pandas add days to date' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
86 def add_day(x): 87 if x not in self.weekdays: 88 self.weekdays.append(x)
40 def add_days(self, days): 41 self._days += days
761 def convert_month_day_to_date_time(self, df, year = 1970): 762 new_index = [] 763 764 # TODO use map? 765 for i in range(0, len(df.index)): 766 x = df.index[i] 767 new_index.append(datetime.date(year, x[0], int(x[1]))) 768 769 df.index = pandas.DatetimeIndex(new_index) 770 771 return df
13 def after_date(all_dates, date): 14 i=len(all_dates)-1 15 while(i>=0): 16 if all_dates[i] <= pd.to_datetime(date): 17 return all_dates[i:] 18 i = i-1 19 raise
69 def add_month_based_on_weekday(date): 70 # Is the weekday of this date the last one? 71 is_last_weekday = (date + datetime.timedelta(weeks=1)).month != date.month 72 73 # Some magic which pushes and pulls some weeks until 74 # it fits right. 75 new_date = date + datetime.timedelta(weeks=4) 76 if (new_date.day + 6) // 7 < (date.day + 6) // 7: 77 new_date += datetime.timedelta(weeks=1) 78 next_month = add_month(date, override_day=1) 79 if new_date.month == (next_month.month - 1 if next_month.month > 1 else 12): 80 new_date += datetime.timedelta(weeks=1) 81 elif new_date.month == (next_month.month + 1 if next_month.month < 12 else 1): 82 new_date += datetime.timedelta(weeks=-1) 83 84 # If the weekdate of the original date was the last one, 85 # and there is some room left, add a week extra so this 86 # will result in a last weekday of the month again. 87 if is_last_weekday and (new_date + datetime.timedelta(weeks=1)).month == new_date.month: 88 new_date += datetime.timedelta(weeks=1) 89 90 return new_date
48 def previous_day(date, skip_weekends): 49 """ 50 Returns the previous day. Takes a datetime.date object. 51 52 If skip_weekends is True, then the day before a Friday is the preceding 53 Monday. 54 """ 55 return _increment_day(date, skip_weekends, -1)
162 @register.filter(name='as_days') 163 def as_days(dates): 164 return sorted([date.date.day for date in dates])
668 def add_years(d, years): 669 """ 670 Add 'year' years to the date 'd'. 671 672 Return a date that's `years` years after the date (or datetime) 673 object `d`. Return the same calendar date (month and day) in the 674 destination year, if it exists, otherwise use the following day 675 (thus changing February 29 to March 1). 676 source: https://stackoverflow.com/a/15743908/1518684 677 678 Parameters: 679 ---------- 680 d: datetime.date 681 The date to which 'years' years should be added. 682 years: int 683 The number of years to add to date. 684 685 Returns: 686 ---------- 687 new_d: datetime.date 688 Date d incremented by 'years' years. 689 690 """ 691 try: 692 return d.replace(year = d.year + years) 693 except ValueError: 694 return d + (date(d.year + years, 1, 1) - date(d.year, 1, 1))
106 def add_working_days(self, day, delta, 107 extra_working_days=None, extra_holidays=None, 108 keep_datetime=False): 109 extra_working_days = extra_working_days or self.extra_working_days 110 return super().add_working_days(day, delta, 111 extra_working_days, 112 extra_holidays, 113 keep_datetime)
517 def daysbetween(day1, month1, year1, day2, month2, year2): 518 """Given two dates it returns the number of days between them. 519 If date1 is earlier than date2 then the result will be positive.""" 520 return daycount(year2, month2, day2) - daycount(year1, month1, day1)