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
.a is correctly returned as numpy.int64 in all cases, except for the last line when I use t2_str and suddenly it's a one element Series containing the numpy.int64.
I have no idea what on earth is going on, it took a lot of 🔍 to get a repro.
I found it while writing a unit test where I was passing a timestamp from test data as a string.
If you remove the .replace(microsecond=0) you'll see it works as expected 🤯
Expected Behavior
.loc should be consistent before and after a concat.
Installed Versions
INSTALLED VERSIONS
commit : bdc79c1
python : 3.11.6.final.0
python-bits : 64
OS : Linux
OS-release : 6.2.0-1019-azure
Version : #19~22.04.1-Ubuntu SMP Wed Jan 10 22:57:03 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
Maybe, @jbrockmendel knows more, he last changed the relevant code in datetime._parse_with_reso.
There is some additional logic for handling the lookup with str labels on a DateTimeIndex that infers a lookup-resolution from the string itself. In the end, the str(t2) has no zero'd microseconds in it, thus a sec resolution is inferred, matching both t1and t2.
If one wants to keep this feature of resolution dependent lookup, one would have to add the trailing zeros to times like str(t2) manually, since datetime always removes them from what I could see.
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
.a
is correctly returned asnumpy.int64
in all cases, except for the last line when I uset2_str
and suddenly it's a one elementSeries
containing thenumpy.int64
.I have no idea what on earth is going on, it took a lot of 🔍 to get a repro.
I found it while writing a unit test where I was passing a timestamp from test data as a string.
If you remove the
.replace(microsecond=0)
you'll see it works as expected 🤯Expected Behavior
.loc
should be consistent before and after aconcat
.Installed Versions
INSTALLED VERSIONS
commit : bdc79c1
python : 3.11.6.final.0
python-bits : 64
OS : Linux
OS-release : 6.2.0-1019-azure
Version : #19~22.04.1-Ubuntu SMP Wed Jan 10 22:57:03 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.1
numpy : 1.26.1
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
dataframe-api-compat : None
fastparquet : 2023.2.0
fsspec : 2023.10.0
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 14.0.1
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: