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

Adding Period and Offset not implemented #6779

Closed
jseabold opened this issue Apr 3, 2014 · 4 comments
Closed

Adding Period and Offset not implemented #6779

jseabold opened this issue Apr 3, 2014 · 4 comments
Labels
API Design Datetime Datetime data dtype Period Period data type
Milestone

Comments

@jseabold
Copy link
Contributor

jseabold commented Apr 3, 2014

This works

from pandas.tseries.frequencies import to_offset
pd.Timestamp('1990-9-30') + 2*to_offset('Q')

This doesn't. Shouldn't it? Workaround is to convert with to_timestamp.

pd.Period('1990q1') + 2*to_offset('Q')
@jreback
Copy link
Contributor

jreback commented Apr 3, 2014

You want this, but also ability to do it with an offset. What if the offset is incompatible to the inferred_freq, raise?

In [17]: pd.Period('1990q1')
Out[17]: Period('1990Q1', 'Q-DEC')

In [18]: pd.Period('1990q1') + 2
Out[18]: Period('1990Q3', 'Q-DEC')

@jseabold
Copy link
Contributor Author

jseabold commented Apr 3, 2014

Hmm, maybe that is sufficient. I guess I was expecting to work in both cases with a conformable offset, so I can treat period and timestamp the same and not special case everything.

I'm starting to think this is a design problem on our end though and we should special case for PeriodIndex vs DatetimeIndex with a freq. I'm not really sure. I'd like to be able to treat them both the same, but I don't know if that's a reasonable expectation.

@jreback
Copy link
Contributor

jreback commented Apr 3, 2014

hmm. they should have the same API, but right now they inherit from the base class separately, so this is kind of tricky

This will fix it (and its not really that hard), just need to find time for this: #6469

But I agree they should be pretty comparable.

That said, I think we can leave this issue open for now (i'll link to the other one), for reference

@jreback jreback added this to the 0.15.0 milestone Apr 3, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@jorisvandenbossche
Copy link
Member

This seems to work now:

In [57]: pd.Period('1990q1')
Out[57]: Period('1990Q1', 'Q-DEC')

In [58]: pd.Period('1990q1') + 2*to_offset('Q')
Out[58]: Period('1990Q3', 'Q-DEC')

and was closed by #7966 (which already included tests for this)

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 Period Period data type
Projects
None yet
Development

No branches or pull requests

3 participants