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
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.