-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
pd.Period off by hundred of years for dates past ~2263 #13346
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
Comments
http://pandas.pydata.org/pandas-docs/stable/timeseries.html#timestamp-limitations there are limitations on the repr of Timestamps. |
you can represent as |
I suppose this should actually raise. |
+1 for raising an Exception Is another way to get the year-month-day corresponding to end_time/start_time of the given period? |
actually this should catch the oob error and just return a datetime |
Don't have enough context about how pd.Period is used throughout pandas... But having the return type change based on a non-obvious criteria could lead to problems as well. If possible would be nice to get a consistent type out (datetime). |
Timestamp is a subclass of datetime |
Currently offsets coerces to normal
|
Could |
bump |
you are welcome to contribute a PR to fix. |
On master
Raises the following: OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 2300-02-01 00:00:00 Full traceback: ---------------------------------------------------------------------------
OutOfBoundsDatetime Traceback (most recent call last)
<ipython-input-2-47b0a5c0011f> in <module>
----> 1 pd.Period(year=2300, month=1, day=1, freq='M').end_time
~/Documents/Github/Community/Python/Projects/pandas-MomIsBestFriend/pandas/_libs/tslibs/period.pyx in pandas._libs.tslibs.period._Period.end_time.__get__()
1765 # freq.n can't be negative or 0
1766 # ordinal = (self + self.freq.n).start_time.value - 1
-> 1767 ordinal = (self + self.freq).start_time.value - 1
1768 return Timestamp(ordinal)
1769
~/Documents/Github/Community/Python/Projects/pandas-MomIsBestFriend/pandas/_libs/tslibs/period.pyx in pandas._libs.tslibs.period._Period.start_time.__get__()
1759 Timestamp('2012-01-01 23:59:59.999999999')
1760 """
-> 1761 return self.to_timestamp(how='S')
1762
1763 @property
~/Documents/Github/Community/Python/Projects/pandas-MomIsBestFriend/pandas/_libs/tslibs/period.pyx in pandas._libs.tslibs.period._Period.to_timestamp()
1804 val = self.asfreq(freq, how)
1805
-> 1806 dt64 = period_ordinal_to_dt64(val.ordinal, base)
1807 return Timestamp(dt64, tz=tz)
1808
~/Documents/Github/Community/Python/Projects/pandas-MomIsBestFriend/pandas/_libs/tslibs/period.pyx in pandas._libs.tslibs.period.period_ordinal_to_dt64()
1184 get_date_info(ordinal, freq, &dts)
1185
-> 1186 check_dts_bounds(&dts)
1187 return dtstruct_to_dt64(&dts)
1188
~/Documents/Github/Community/Python/Projects/pandas-MomIsBestFriend/pandas/_libs/tslibs/np_datetime.pyx in pandas._libs.tslibs.np_datetime.check_dts_bounds()
118 fmt = (f'{dts.year}-{dts.month:02d}-{dts.day:02d} '
119 f'{dts.hour:02d}:{dts.min:02d}:{dts.sec:02d}')
--> 120 raise OutOfBoundsDatetime(f'Out of bounds nanosecond timestamp: {fmt}')
121
122
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 2300-02-01 00:00:00 Installed versions: INSTALLED VERSIONScommit : 4b64f98 pandas : 1.1.0.dev0+948.g4b64f9809 @jreback Should we add a regression test for this? |
* #TST pandas-dev#13346 added tests * TST pandas-dev#13346 taken review into account * Added tests for pandas-dev#13346 - with review
* #TST pandas-dev#13346 added tests * TST pandas-dev#13346 taken review into account * Added tests for pandas-dev#13346 - with review
Input year is '2300', output shows '1715'
output of
pd.show_versions()
In [3]: pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Linux
OS-release: 3.19.0-25-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.1
nose: None
pip: 7.1.2
setuptools: 21.0.0
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.2.0
sphinx: None
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
pandas_datareader: 0.2.1
The text was updated successfully, but these errors were encountered: