Skip to content

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

@jseabold

Description

@jseabold
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.

Activity

hayd

hayd commented on Jul 11, 2013

@hayd
Contributor

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

jseabold commented on Jul 11, 2013

@jseabold
ContributorAuthor

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

jreback commented on Jul 11, 2013

@jreback
Contributor

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

jreback commented on Jul 11, 2013

@jreback
Contributor
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

jseabold commented on Jul 11, 2013

@jseabold
ContributorAuthor

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

jreback

jreback commented on Jul 11, 2013

@jreback
Contributor

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

ghost assigned on Sep 27, 2013
modified the milestones: 0.15.0, 0.14.0 on Mar 30, 2014
modified the milestones: 0.16.0, Next Major Release on Mar 3, 2015
jbrockmendel

jbrockmendel commented on Dec 11, 2019

@jbrockmendel
Member

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

modified the milestones: Contributions Welcome, 1.0 on Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @jseabold@WillAyd@jreback@hayd@jbrockmendel

    Issue actions

      API: deprecate get_offset, Offset for time rules like '30s' · Issue #4205 · pandas-dev/pandas