question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API: Add Calendar Day Frequency ("CD")

See original GitHub issue

This is a proposal to replace #20633.

offsets.Day ('D') is documented to represent calendar day; however, Day arithmetic and usage of the 'D' offset alias (e.g. df.resample('D'), timedelta_range(..., freq='D'), etc.) currently respects absolute time (i.e. Day acts like Timedelta(days=1)). This usage is ingrained pretty deeply in a lot of methods and operations and is fairly difficult to walk back to respect the notion of calendar day as stated in the docs.

Instead, I propose to keep Day as is (a timedelta-like frequency like Hour ('H')) and add a new frequency CalendarDay, 'CD'. It would act very similarly to DateOffset(day=1) but act like a frequency. Thoughts?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:31 (31 by maintainers)

github_iconTop GitHub Comments

1reaction
chris-b1commented, Aug 11, 2018

Only partially related, but I’ve also thought it would be nice to have frequencies for other DateOffset cases, e.g. a calendar year like the below.

In [7]: pd.date_range('2014-01-15', periods=10, freq=pd.DateOffset(years=1))
Out[7]: 
DatetimeIndex(['2014-01-15', '2015-01-15', '2016-01-15', '2017-01-15',
               '2018-01-15', '2019-01-15', '2020-01-15', '2021-01-15',
               '2022-01-15', '2023-01-15'],
              dtype='datetime64[ns]', freq='<DateOffset: kwds={'years': 1}>')

So, maybe a whole set of 'CD', 'CM', 'CA'?

0reactions
mroeschkecommented, Sep 27, 2018

Closing in favor of further discussion in #22864 (especially about deprecation procedure)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Events: insert | Google Calendar
Property name Value Notes end nested object start nested object anyoneCanAddSelf boolean writable
Read more >
8 DateOffset objects — Pandas Doc - GitHub Pages
DateOffset, Generic offset class, defaults to 1 calendar day. BDay, business day (weekday). CDay, custom business day (experimental).
Read more >
oracle.as.scheduler Class Recurrence
Frequency is always mandatory when defining a recurrence pattern based on recurrence fields. ... Method to add a day of month to this...
Read more >
5.5. Date and Time Calendar - Python
tseries.holiday import AbstractHolidayCalendar, Holiday, EasterMonday, Easter >>> from pandas.tseries.offsets import Day, CustomBusinessDay, CustomBusinessHour ...
Read more >
Get business days between start and end date using pandas
You can also use date_range for this purpose. In [3]: pd.date_range('2011-01-05', '2011-01-09', freq=BDay()) Out[3]: DatetimeIndex(['2011-01-05', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found