-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
import datetime
import pandas as pd
dates = pd.bdate_range('2020-04-20', '2020-04-25')
print(dates.get_indexer([datetime.date(2020, 4, 20), datetime.date(2020, 4, 21)]))
# [0, 1]
print(dates.get_indexer([pd.Timestamp('2020-04-20'), datetime.date(2020, 4, 21)]))
# [0, -1]
Problem description
As a general rule I would expect that index.get_indexer(as + bs) == np.concat([index.get_indexer(as), index.get_indexer(bs)])
for any lists as
and bs
, i.e. index.get_indexer
operates elementwise. However in this case the type of a previous argument is surprisingly affecting the index that is assigned to a later one.
Expected Output
[0, 1]
in both cases
Output of pd.show_versions()
pandas : 1.0.3
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.1.3.post20200330
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None