Skip to content
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

API: deprecate get_offset, Offset for time rules like '30s' #4205

Closed
jseabold opened this issue Jul 11, 2013 · 7 comments · Fixed by #30340
Closed

API: deprecate get_offset, Offset for time rules like '30s' #4205

jseabold opened this issue Jul 11, 2013 · 7 comments · Fixed by #30340
Assignees
Labels
API Design Datetime Datetime data dtype Deprecate Functionality to remove in pandas Usage Question
Milestone

Comments

@jseabold
Copy link
Contributor

From stackoverflow: http://stackoverflow.com/questions/17579932/statsmodel-arma-function-is-incompatiable-with-pandas/17581170

I'm looking only quickly at this, but I'm wondering if this should be recognized and return an offset.

from pandas.tseries.frequencies import get_offset
get_offset('30s')

or if in statsmodels we should accept custom offsets in place of frequency strings.

@hayd
Copy link
Contributor

hayd commented Jul 11, 2013

Perhaps poor implementation (seems very hacky), but perhaps something like:

In [11]: s = '30S'

In [12]: m = re.match('(?P<number>\d+)(?P<offset>.*)', s)

In [13]: int(m.groupdict()['number']) * get_offset(m.groupdict()['offset'])
Out[13]: <30 Seconds>

should be done on the pandas side.

@jseabold
Copy link
Contributor Author

That's what I had in mind as long as it's valid for any integer + existing offset. I'll go ahead and add a workaround on our side like this.

@jreback
Copy link
Contributor

jreback commented Jul 11, 2013

All kinds of goodies in there.....is this in the docs?

In [1]: from pandas.tseries.frequencies import to_offset

In [2]: to_offset('30s')
Out[2]: <30 Seconds>

@jreback
Copy link
Contributor

jreback commented Jul 11, 2013

def get_offset(name):
    """
    Return DateOffset object associated with rule name

    Examples
    --------
    get_offset('EOM') --> BMonthEnd(1)
    """
def to_offset(freqstr):
    """
    Return DateOffset object from string representation

    Examples
    --------
    >>> to_offset('5Min')
    Minute(5)
    """

@jseabold
Copy link
Contributor Author

Ah, great. Any need to keep these functions separate? get_ seems like a subset of to_ to me (without looking at the source).

@jreback
Copy link
Contributor

jreback commented Jul 11, 2013

that sounds right.....so changing this issue to deprectate get_offset..thxs

@jbrockmendel
Copy link
Member

This isn't exposed in tseries.api or anywhere, does it actually need to be deprecated? could privatize?

@jreback jreback modified the milestones: Contributions Welcome, 1.0 Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Datetime Datetime data dtype Deprecate Functionality to remove in pandas Usage Question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants