Skip to content

Period() docstring inconsistent with code when freq has a mult != 1 #4699

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

Closed
JackKelly opened this issue Aug 28, 2013 · 2 comments · Fixed by #5057
Closed

Period() docstring inconsistent with code when freq has a mult != 1 #4699

JackKelly opened this issue Aug 28, 2013 · 2 comments · Fixed by #5057
Labels
Milestone

Comments

@JackKelly
Copy link
Contributor

(I love Pandas! Great work! One small issue...)

The docstring for the Period constructor reads:

freq : str, default None
    e.g., 'B' for businessday, ('T', 5) or '5T' for 5 minutes

i.e. the docstring says that freq can be multiples of a period code (e.g. 5 minutes).

But if we try to use mult != 1 then we get an exception:

In [43]: pd.Period('2013-01-01', freq='5T')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-43-770fd8956b5c> in <module>()
----> 1 pd.Period('2013-01-01', freq='5T')

/usr/local/lib/python2.7/dist-packages/pandas/tseries/period.pyc in __init__(self, value, freq, ordinal, year, month, quarter, day, hour, minute, second)
    120         base, mult = _gfc(freq)
    121         if mult != 1:
--> 122             raise ValueError('Only mult == 1 supported')
    123 
    124         if self.ordinal is None:

ValueError: Only mult == 1 supported

This same error is given if we provide freq as a tuple like freq=('T', 5)

So either the code can't handle mult != 1 (in which case the docstring is wrong). Or, if the docstring is correct (the code can handle a mult != 1) then the exception is wrong.

(For my own work, I would love to be able to use arbitrary-length Period instances. Here's a related StackOverflow question that I have just asked: Irregular, non-contiguous Periods in Pandas)

(I'm using Pandas 0.12)

@jreback
Copy link
Contributor

jreback commented Sep 30, 2013

@JackKelly PR for the doc change?

@JackKelly
Copy link
Contributor Author

@jreback Sure thing. Here's a pull request with a very simple DOC change: #5057

jreback added a commit that referenced this issue Oct 4, 2013
DOC: proposed fix for #4699: Period() docstring inconsistent with code when freq has a mult != 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants