You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While preparing our code for Pandas 2, we noticed the following:
1. Different ways of Timestamp creation ends up in a different timestamp unit
pd.Timestamp("010120") -> Timestamp('2020-01-01 00:00:00') with unit = 's' pd.Timestamp(2020, 1, 1) -> Timestamp('2020-01-01 00:00:00') with `unit = 'us'
Moreover I could create Timestamps, which I cannot reproduce with using pd.Timestamp.
Let us take the first timestamp from above:
t=pd.Timestamp("010120")
tmax=t.max
We get tmax = Timestamp('292277026596-12-04 15:30:07') where it is at least not possible to create a Timestamp with a year greater than 9999.
t_impossible=pd.Timestamp(10000,1,1)
lead to
ValueError Traceback (most recent call last)
Cell In[29], line 1
----> 1 pd.Timestamp(10000,1,1)
File ~/venv/myvenv/lib/python3.10/site-packages/pandas/_libs/tslibs/timestamps.pyx:1645, in pandas._libs.tslibs.timestamps.Timestamp.__new__()
ValueError: year 10000 is out of range
I even cannot count on a timestamp that is outside the max values (pd.Timestamp.max = Timestamp('2262-04-11 23:47:16.854775807') and pd.Timestamp.min = Timestamp('1677-09-21 00:12:43.145224193'))
To what extent is the behaviour intentional or erroneous?
With pandas 1.5.3 it was not possible to create timestamps greater than pd.Timestamp.max due to its ns-representation.
Expected Behavior
I don't know if it is even a bug, but I would expect, that I can create timestamp (e.g. year > 10000) and that I can calculate with timestamps (e.g. 2300-01-01 + 100 days) [ not in every unit, but if the unit allows it, why not?
Installed Versions
INSTALLED VERSIONS
python : 3.10.2.final.0
python-bits : 64
OS : Darwin
OS-release : 22.1.0
Version : Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.UTF-8
kaibir
changed the title
BUG?: Generating timestamps and calculation?
BUG or as expected/designed?: Generating timestamps and calculation?
Mar 20, 2023
kaibir
changed the title
BUG or as expected/designed?: Generating timestamps and calculation?
BUG or as expected/designed?: Generating and calculation with timestamps out of bound?
Mar 27, 2023
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
While preparing our code for Pandas 2, we noticed the following:
1. Different ways of Timestamp creation ends up in a different timestamp unit
pd.Timestamp("010120")
-> Timestamp('2020-01-01 00:00:00') withunit = 's'
pd.Timestamp(2020, 1, 1)
-> Timestamp('2020-01-01 00:00:00') with `unit = 'us'Moreover I could create Timestamps, which I cannot reproduce with using
pd.Timestamp
.Let us take the first timestamp from above:
We get
tmax = Timestamp('292277026596-12-04 15:30:07')
where it is at least not possible to create a Timestamp with a year greater than 9999.lead to
I even cannot count on a timestamp that is outside the max values (pd.Timestamp.max = Timestamp('2262-04-11 23:47:16.854775807') and pd.Timestamp.min = Timestamp('1677-09-21 00:12:43.145224193'))
To what extent is the behaviour intentional or erroneous?
With pandas 1.5.3 it was not possible to create timestamps greater than pd.Timestamp.max due to its ns-representation.
Expected Behavior
I don't know if it is even a bug, but I would expect, that I can create timestamp (e.g. year > 10000) and that I can calculate with timestamps (e.g. 2300-01-01 + 100 days) [ not in every unit, but if the unit allows it, why not?
Installed Versions
INSTALLED VERSIONS
python : 3.10.2.final.0
python-bits : 64
OS : Darwin
OS-release : 22.1.0
Version : Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.UTF-8
pandas : 2.0.0rc1
numpy : 1.23.5
pytz : 2022.6
dateutil : 2.8.2
setuptools : 65.6.3
pip : 22.3.1
Cython : None
pytest : 7.2.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : 2.9.5
jinja2 : 3.1.2
IPython : 8.7.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2022.11.0
gcsfs : 2022.11.0
matplotlib : 3.6.2
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.9.3
snappy : None
sqlalchemy : 1.4.45
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: