>> df["B"] = other ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series >...">

BUG: frame_length_0[key] = nonempty_frame raises ValueError · Issue #38831 · pandas-dev/pandas (original) (raw)

df = pd.DataFrame(columns=["A", "B"])

other = pd.DataFrame({"B": [1, 2]})

>>> df["B"] = other
ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series

>>> df[["B"]] = other   # <-- works as expected