-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: When using np.datetime64 should have date ranges according to frequency #4066
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
pandas doesn't support these types of date frequencies |
I have a general purpose astronomic library that currently can use second level frequency and range from around 4700 BCE to sometime in the far future (5000 CE? something like that). It is called Astronomia at https://bitbucket.org/timcera/astronomia. The date data structure, if you can call it that, is very primitive with year, month, day, hour, minute, second passed around as separate scalars, or in my development version separate numpy arrays. That data structure isn't necessarily a bad thing, it gets converted pretty quickly to Julian Day Number or Julian Date that drives almost all of the other calculations. I thought that Pandas would give me a better environment, but if I move to Pandas, I don't want to lose any functionality. At a minimum, the frequencies that aren't supported should be documented and raise an error. Kindest regards, |
@jreback should Timestamps raise here (as out of bounds)? This seems a little stange/buggy (why are we converting this dtype to a Timestamp?):
A workaround is to use the object dtype (obviously not ideal)
@jreback I'm not saying these should be allowable times for Timestamp, but perhaps we (c|sh)ould allow this dtype (i.e. not try and attempt the conversion if the dtype is prescribed... or something?):
weird:
|
yes, this should raise |
Is there a reason this dtype isn't allowed? Rather than raise |
everything converted internally to
then |
@jreback so the problem is converting ns raises / loses data, so it's not as simple as just returning values rather than raising in _possibly_cast_to_datetime? (but maybe raise if coerce=True). |
The problem is the conversion wasn't always working, so instead of having a weird result was just not allowing it (as there are many ways to input the dates in any event), just an issue with using |
pushing to 0.14. maybe can support different datetime freqs |
@jreback closeable? |
yes we raise appropriately for out of bounds |
A daily frequency np.datetime64 should have a range of [2.5e16 BC, 2.5e16 AD]. Instead it follows the range for nanosecond [ 1678 AD, 2262 AD].
Ranges taken from http://docs.scipy.org/doc/numpy/reference/arrays.datetime.html
In [126]: pd.Timestamp(np.datetime64('1677-01-01'),'D')
Out[126]: Timestamp('2261-07-22 23:34:33.709551616', tz=None)
In [127]: pd.Timestamp(np.datetime64('1678-01-01'),'D')
Out[127]: Timestamp('1678-01-01 00:00:00', tz=None)
In [128]: pd.Timestamp(np.datetime64('2262-01-01'),'D')
Out[128]: Timestamp('2262-01-01 00:00:00', tz=None)
In [129]: pd.Timestamp(np.datetime64('2263-01-01'),'D')
Out[129]: Timestamp('1678-06-12 00:25:26.290448384', tz=None)
The text was updated successfully, but these errors were encountered: