File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -614,10 +614,10 @@ def sanitize_array(
614614 # GH#61026: special-case 2D+ object ndarrays when dtype is None.
615615 if data .dtype == object and data .ndim > 1 :
616616 if data .ndim == 2 and data .shape [1 ] == 1 :
617- # allow assigning a (n, 1) object array to a single column, flatten it:
617+ # allow assigning a (n, 1) object array to a single column.
618618 data = data [:, 0 ]
619619 elif data .ndim == 2 :
620- # More than one column but caller is behaving as if this is a single-column assignment .
620+ # more than 1 column, now allowed .
621621 raise ValueError (
622622 "Setting a DataFrame column with a 2D object array "
623623 f"requires shape (n, 1); got shape { data .shape } ."
@@ -628,7 +628,7 @@ def sanitize_array(
628628 f"Setting a DataFrame column with ndim { data .ndim } "
629629 "object array is not supported."
630630 )
631-
631+
632632 subarr = data
633633 if data .dtype == object and infer_object :
634634 subarr = lib .maybe_convert_objects (
Original file line number Diff line number Diff line change 11import numpy as np
2+ import pytest
3+
24import pandas as pd
35import pandas ._testing as tm
4- import pytest
56
67
78class TestSetItem2DObjectArray :
You can’t perform that action at this time.
0 commit comments