woodwork
woodwork copied to clipboard
Support multiple column assignment via woodwork accessor
Currently if a user attempts to assign multiple columns using the woodwork accessor, an error is thrown.
def test_multiple_assignment():
df = pd.DataFrame()
df["ints"] = [i for i in range(100)]
df["bools"] = [True, False, True, False] * 25
df["datetime"] = pd.date_range("1/1/21", periods=100)
df_ = pd.DataFrame()
df_["ints_"] = [f"{i * 2}" for i in range(100)]
df_["bools_"] = [f"{i * 5}" for i in range(100)]
df.ww.init()
df.ww[["ints", "bools"]] = df_
---------------------------------------
ValueError: New column must be of Series type
Whereas
def test_multiple_assignment():
df = pd.DataFrame()
df["ints"] = [i for i in range(100)]
df["bools"] = [True, False, True, False] * 25
df["datetime"] = pd.date_range("1/1/21", periods=100)
df_ = pd.DataFrame()
df_["ints_"] = [f"{i * 2}" for i in range(100)]
df_["bools_"] = [f"{i * 5}" for i in range(100)]
df[["ints", "bools"]] = df_
yields the correct assignment