Skip to content

Add "day of month" (e.g., 15th of month) frequencies, easier extension? #2289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wesm opened this issue Nov 19, 2012 · 5 comments
Open

Add "day of month" (e.g., 15th of month) frequencies, easier extension? #2289

wesm opened this issue Nov 19, 2012 · 5 comments
Labels
Datetime Datetime data dtype Enhancement Frequency DateOffsets

Comments

@wesm
Copy link
Member

wesm commented Nov 19, 2012

http://stackoverflow.com/questions/13445174/date-ranges-in-pandas

@poswald
Copy link

poswald commented May 19, 2013

Do you know if there has been any movement on this at all since it was identified? The data I am looking at has bursts of activity monthly that aligns on the last day and 1st days of the month so month-over-month analysis would benefit considerably from being able to offset by X days to get mid-month reports. Thanks!

@jreback
Copy link
Contributor

jreback commented May 19, 2013

@poswald this is not a solution, but a straightforward way to create the day-of-month index (its still not the right frequency), but still may work for what you need

In [27]: from datetime import timedelta

In [28]: Index(Series(date_range('20130115',freq='MS',periods=10).tolist()) + timedelta(days=14))
Out[28]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-02-15 00:00:00, ..., 2013-11-15 00:00:00]
Length: 10, Freq: None, Timezone: None

In [29]: Index(Series(date_range('20130115',freq='MS',periods=10).tolist()) + timedelta(days=14)).tolist()
Out[29]: 
[Timestamp('2013-02-15 00:00:00', tz=None),
 Timestamp('2013-03-15 00:00:00', tz=None),
 Timestamp('2013-04-15 00:00:00', tz=None),
 Timestamp('2013-05-15 00:00:00', tz=None),
 Timestamp('2013-06-15 00:00:00', tz=None),
 Timestamp('2013-07-15 00:00:00', tz=None),
 Timestamp('2013-08-15 00:00:00', tz=None),
 Timestamp('2013-09-15 00:00:00', tz=None),
 Timestamp('2013-10-15 00:00:00', tz=None),
 Timestamp('2013-11-15 00:00:00', tz=None)]

@petrounias
Copy link

Also, it appears that you cannot even shift a PeriodIndex after constructing it, but what's puzzling is that the shift method's documentation states a 'freq' parameter which is missing from the method's signature. Specifically:

def shift(self, n):
    """
    Specialized shift which produces an PeriodIndex

    Parameters
    ----------
    n : int
        Periods to shift by
    freq : freq string

    Returns
    -------
    shifted : PeriodIndex
    """

@petehuang
Copy link
Contributor

Related: #1573

Have there been any developments related to "day of month" frequencies?

@jreback
Copy link
Contributor

jreback commented Dec 29, 2016

We have an implementation of WeekOfMonth, see here, so this would be pretty easy. Not sure how useful it is, so we'll leave this open.

On another note, we are missing documentation of WOM and LWOM (last-week-of-month) in the main docs (at least a reference http://pandas.pydata.org/pandas-docs/stable/timeseries.html?highlight=weekofmonth#offset-aliases would be good (and a small example on usage) if you'd like to do a PR.

@jbrockmendel jbrockmendel added the Frequency DateOffsets label Jul 11, 2018
@mroeschke mroeschke removed this from the Someday milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement Frequency DateOffsets
Projects
None yet
Development

No branches or pull requests

7 participants