Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
# works
df = pd.DataFrame({"A": [1, 1]})
df.loc[[False, False]] = df
# raises
df = pd.DataFrame({"X": [pd.Timestamp(2023, 1, 1)] * 2})
df.loc[[False, False]] = df

Issue Description

If the dataframe contains a datetime or timedelta column, whether there are other coulmns present or not, it will raise:

ValueError: shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (0,)

This does not happen when there is only one row, or when there are no datetime or timedelta columns. Object dtype is also fine, even if the values are timestamps.

On the nightly build we hit an infinite recursion instead of a ValueError.

Possibly related #45981.

Expected Behavior

This should not raise and it should be a no-op:

df = pd.DataFrame({"X": [pd.Timestamp(2023, 1, 1)] * 2})
df.loc[[False, False]] = df

Installed Versions

INSTALLED VERSIONS ------------------ commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.11.1.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19044 machine : AMD64 processor : AMD64 Family 23 Model 8 Stepping 2, AuthenticAMD byteorder : little LC_ALL : None LANG : None LOCALE : English_United States.1252 pandas : 1.5.3 numpy : 1.24.1 pytz : 2022.7.1 dateutil : 2.8.2 setuptools : 65.5.0 pip : 22.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 : None IPython : None pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None zstandard : None tzdata : None

Comment From: topper-123

This works in the main branch, so I'm closing. I don't know when or how this was fixed, which is annoying, but if you see anything here not working as expected, feel free to reopen.