Skip to content

BUG raise pdep6 warning for loc full setter #56146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4644c00
raise pdep6 warning for loc full setter
MarcoGorelli Nov 24, 2023
da7efad
update for stata reader
MarcoGorelli Nov 24, 2023
9e400c2
clean
MarcoGorelli Nov 24, 2023
003b993
clean
MarcoGorelli Nov 24, 2023
3ff469f
wip
MarcoGorelli Nov 24, 2023
e561aa5
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Nov 27, 2023
cd9408e
fixup
MarcoGorelli Nov 27, 2023
58ce78e
more fixups
MarcoGorelli Nov 27, 2023
6564773
fixup remaining tests (but are they right?)
MarcoGorelli Nov 27, 2023
4c345e4
:art:
MarcoGorelli Nov 27, 2023
ea51b08
dont warn on expected
MarcoGorelli Nov 27, 2023
388ded7
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Nov 27, 2023
14c9ff6
cow fixup
MarcoGorelli Nov 27, 2023
846b529
:art:
MarcoGorelli Nov 27, 2023
4f5495c
:art:
MarcoGorelli Nov 27, 2023
9c26bb3
catch len-block>1 case too
MarcoGorelli Nov 27, 2023
3f82a91
fixup tests
MarcoGorelli Nov 27, 2023
874b596
simplify
MarcoGorelli Nov 27, 2023
162586c
simplify
MarcoGorelli Nov 27, 2023
467742c
remove outdated comment
MarcoGorelli Nov 27, 2023
5d24fb0
fixup test_internals test
MarcoGorelli Nov 27, 2023
a43b737
Update indexing unpacking logic for single block case
phofl Nov 27, 2023
24afe06
Merge remote-tracking branch 'phofl/indexing_update' into full-setter…
MarcoGorelli Nov 28, 2023
20c89a2
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Nov 28, 2023
7a25a86
fixing stuff up?
MarcoGorelli Nov 28, 2023
3240bb9
wip try fixing up?
MarcoGorelli Nov 28, 2023
755ded6
try fixup
MarcoGorelli Nov 28, 2023
28a731b
copy-on-write test
MarcoGorelli Nov 28, 2023
27bf409
exclude abcdataframe setting
MarcoGorelli Nov 28, 2023
b1a4777
exclude "expanding empty df" case
MarcoGorelli Nov 28, 2023
5b43509
reduce diff
MarcoGorelli Nov 28, 2023
191ce85
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Nov 28, 2023
428c146
update
MarcoGorelli Nov 28, 2023
12cd484
ooooh this works?
MarcoGorelli Nov 28, 2023
cd208ca
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Dec 4, 2023
3dd4d36
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Dec 4, 2023
45dd43b
reduce diff
MarcoGorelli Dec 4, 2023
54f3459
simplify
MarcoGorelli Dec 4, 2023
96ee0ae
use isetitem
MarcoGorelli Dec 4, 2023
0bc2205
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Dec 4, 2023
e3b04b7
fix comment
MarcoGorelli Dec 4, 2023
c81c486
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Dec 13, 2023
9d604da
Merge branch 'main' into full-setter-pdep6
MarcoGorelli Dec 19, 2023
c1fa7f3
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Dec 20, 2023
7b0e3c8
revert unnecessary change, add link in whatsnew note
MarcoGorelli Dec 20, 2023
183a609
one more
MarcoGorelli Dec 20, 2023
ee0f35d
Merge remote-tracking branch 'upstream/main' into full-setter-pdep6
MarcoGorelli Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ Conversion
^^^^^^^^^^
- Bug in :func:`astype` when called with ``str`` on unpickled array - the array might change in-place (:issue:`54654`)
- Bug in :meth:`Series.convert_dtypes` not converting all NA column to ``null[pyarrow]`` (:issue:`55346`)
- Bug in ``DataFrame.loc`` was not throwing "incompatible dtype warning" (see PDEP6) when assigning a ``Series`` with a different dtype using a full column setter (e.g. ``df.loc[:, 'a'] = incompatible_value``) (:issue:`55791`)
-

Strings
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4157,7 +4157,7 @@ def _get_value(self, index, col, takeable: bool = False) -> Scalar:
loc = engine.get_loc(index)
return series._values[loc]

def isetitem(self, loc, value) -> None:
def isetitem(self, loc, value, *, inplace: bool = False) -> None:
"""
Set the given value in the column with position `loc`.

Expand Down Expand Up @@ -4193,11 +4193,11 @@ def isetitem(self, loc, value) -> None:

for i, idx in enumerate(loc):
arraylike, refs = self._sanitize_column(value.iloc[:, i])
self._iset_item_mgr(idx, arraylike, inplace=False, refs=refs)
self._iset_item_mgr(idx, arraylike, inplace=inplace, refs=refs)
return

arraylike, refs = self._sanitize_column(value)
self._iset_item_mgr(loc, arraylike, inplace=False, refs=refs)
self._iset_item_mgr(loc, arraylike, inplace=inplace, refs=refs)

def __setitem__(self, key, value) -> None:
if not PYPY and using_copy_on_write():
Expand Down Expand Up @@ -4423,7 +4423,7 @@ def _iset_item(self, loc: int, value: Series, inplace: bool = True) -> None:
loc, value._values, inplace=inplace, refs=value._references
)
else:
self._iset_item_mgr(loc, value._values.copy(), inplace=True)
self._iset_item_mgr(loc, value._values.copy(), inplace=inplace)

# check if we are modifying a copy
# try to set first as we want an invalid
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,7 @@ def _setitem_single_column(self, loc: int, value, plane_indexer) -> None:
# If we're setting an entire column and we can't do it inplace,
# then we can use value's dtype (or inferred dtype)
# instead of object
self.obj.isetitem(loc, value)
self.obj.isetitem(loc, value, inplace=True)
else:
# set value into the column (first attempting to operate inplace, then
# falling back to casting if necessary)
Expand Down
32 changes: 32 additions & 0 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,22 @@ def value_getitem(placement):
blk.set_inplace(blk_locs, value_getitem(val_locs))
continue
else:
if inplace and blk.dtype != np.void:
# Exclude np.void, as that is a special case for expansion.
# We want to warn for
# df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
# df.loc[:, 'a'] = .3
# but not for
# df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
# df.loc[:, 'b'] = .3
warnings.warn(
f"Setting an item of incompatible dtype is deprecated "
"and will raise in a future error of pandas. "
f"Value '{value}' has dtype incompatible with {blk.dtype}, "
"please explicitly cast to a compatible dtype first.",
FutureWarning,
stacklevel=find_stack_level(),
)
unfit_mgr_locs.append(blk.mgr_locs.as_array[blk_locs])
unfit_val_locs.append(val_locs)

Expand Down Expand Up @@ -1326,6 +1342,22 @@ def _iset_single(
iloc = self.blklocs[loc]
blk.set_inplace(slice(iloc, iloc + 1), value, copy=copy)
return
elif inplace and blk.dtype != np.void:
# Exclude np.void, as that is a special case for expansion.
# We want to warn for
# df = pd.DataFrame({'a': [1, 2]})
# df.loc[:, 'a'] = .3
# but not for
# df = pd.DataFrame({'a': [1, 2]})
# df.loc[:, 'b'] = .3
warnings.warn(
f"Setting an item of incompatible dtype is deprecated "
"and will raise in a future error of pandas. "
f"Value '{value}' has dtype incompatible with {blk.dtype}, "
"please explicitly cast to a compatible dtype first.",
FutureWarning,
stacklevel=find_stack_level(),
)

nb = new_block_2d(value, placement=blk._mgr_locs, refs=refs)
old_blocks = self.blocks
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ def read(
if convert_dates:
for i, fmt in enumerate(self._fmtlist):
if any(fmt.startswith(date_fmt) for date_fmt in _date_formats):
data.iloc[:, i] = _stata_elapsed_date_to_datetime_vec(
data[data.columns[i]] = _stata_elapsed_date_to_datetime_vec(
Copy link
Member

@phofl phofl Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does stata allow duplicated columns? This is buggy if the answer is yes

We have to operate positional, so you want isetitem here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for all the other occurrences, I prefer isetitem even if stata disallows duplicated columns

data.iloc[:, i], fmt
)

Expand Down Expand Up @@ -1866,7 +1866,7 @@ def _do_convert_missing(self, data: DataFrame, convert_missing: bool) -> DataFra
replacements[i] = replacement
if replacements:
for idx, value in replacements.items():
data.iloc[:, idx] = value
data[data.columns[idx]] = value
return data

def _insert_strls(self, data: DataFrame) -> DataFrame:
Expand All @@ -1876,7 +1876,7 @@ def _insert_strls(self, data: DataFrame) -> DataFrame:
if typ != "Q":
continue
# Wrap v_o in a string to allow uint64 values as keys on 32bit OS
data.iloc[:, i] = [self.GSO[str(k)] for k in data.iloc[:, i]]
data[data.columns[i]] = [self.GSO[str(k)] for k in data.iloc[:, i]]
return data

def _do_select_columns(self, data: DataFrame, columns: Sequence[str]) -> DataFrame:
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/copy_view/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,12 +1129,16 @@ def test_set_value_copy_only_necessary_column(
df_orig = df.copy()
view = df[:]

if val == "a" and indexer[0] != slice(None):
# TODO(CoW-warn) assert the FutureWarning for CoW is also raised
if val == "a" and not warn_copy_on_write:
with tm.assert_produces_warning(
FutureWarning, match="Setting an item of incompatible dtype is deprecated"
):
indexer_func(df)[indexer] = val
if val == "a" and warn_copy_on_write:
with tm.assert_produces_warning(
FutureWarning, match="incompatible dtype|Setting a value on a view"
):
indexer_func(df)[indexer] = val
else:
with tm.assert_cow_warning(warn_copy_on_write):
indexer_func(df)[indexer] = val
Expand Down
35 changes: 20 additions & 15 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,14 @@ def test_setitem(self, float_frame, using_copy_on_write, warn_copy_on_write):
def test_setitem2(self):
# dtype changing GH4204
df = DataFrame([[0, 0]])
df.iloc[0] = np.nan
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.iloc[0] = np.nan
expected = DataFrame([[np.nan, np.nan]])
tm.assert_frame_equal(df, expected)

df = DataFrame([[0, 0]])
df.loc[0] = np.nan
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.loc[0] = np.nan
tm.assert_frame_equal(df, expected)

def test_setitem_boolean(self, float_frame):
Expand Down Expand Up @@ -934,7 +936,8 @@ def test_setitem_frame_upcast(self):
# needs upcasting
df = DataFrame([[1, 2, "foo"], [3, 4, "bar"]], columns=["A", "B", "C"])
df2 = df.copy()
df2.loc[:, ["A", "B"]] = df.loc[:, ["A", "B"]] + 0.5
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df2.loc[:, ["A", "B"]] = df.loc[:, ["A", "B"]] + 0.5
expected = df.reindex(columns=["A", "B"])
expected += 0.5
expected["C"] = df["C"]
Expand Down Expand Up @@ -1372,33 +1375,35 @@ def test_loc_expand_empty_frame_keep_midx_names(self):
tm.assert_frame_equal(df, expected)

@pytest.mark.parametrize(
"val, idxr, warn",
"val, idxr",
[
("x", "a", None), # TODO: this should warn as well
("x", ["a"], None), # TODO: this should warn as well
(1, "a", None), # TODO: this should warn as well
(1, ["a"], FutureWarning),
("x", "a"),
("x", ["a"]),
(1, "a"),
(1, ["a"]),
],
)
def test_loc_setitem_rhs_frame(self, idxr, val, warn):
def test_loc_setitem_rhs_frame(self, idxr, val):
# GH#47578
df = DataFrame({"a": [1, 2]})

with tm.assert_produces_warning(
warn, match="Setting an item of incompatible dtype"
FutureWarning, match="Setting an item of incompatible dtype"
):
df.loc[:, idxr] = DataFrame({"a": [val, 11]}, index=[1, 2])
expected = DataFrame({"a": [np.nan, val]})
tm.assert_frame_equal(df, expected)

@td.skip_array_manager_invalid_test
def test_iloc_setitem_enlarge_no_warning(self, warn_copy_on_write):
def test_iloc_setitem_enlarge_no_warning(
self, warn_copy_on_write, using_copy_on_write
):
# GH#47381
df = DataFrame(columns=["a", "b"])
expected = df.copy()
view = df[:]
# TODO(CoW-warn) false positive: shouldn't warn in case of enlargement?
with tm.assert_produces_warning(FutureWarning if warn_copy_on_write else None):
# TODO(pdep6-warn) false positive: shouldn't warn in case of enlargement?
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.iloc[:, 0] = np.array([1, 2], dtype=np.float64)
tm.assert_frame_equal(view, expected)

Expand Down Expand Up @@ -1963,7 +1968,7 @@ def _check_setitem_invalid(self, df, invalid, indexer, warn):
np.datetime64("NaT"),
np.timedelta64("NaT"),
]
_indexers = [0, [0], slice(0, 1), [True, False, False]]
_indexers = [0, [0], slice(0, 1), [True, False, False], slice(None, None, None)]

@pytest.mark.parametrize(
"invalid", _invalid_scalars + [1, 1.0, np.int64(1), np.float64(1)]
Expand All @@ -1977,7 +1982,7 @@ def test_setitem_validation_scalar_bool(self, invalid, indexer):
@pytest.mark.parametrize("indexer", _indexers)
def test_setitem_validation_scalar_int(self, invalid, any_int_numpy_dtype, indexer):
df = DataFrame({"a": [1, 2, 3]}, dtype=any_int_numpy_dtype)
if isna(invalid) and invalid is not pd.NaT:
if isna(invalid) and invalid is not pd.NaT and not np.isnat(invalid):
warn = None
else:
warn = FutureWarning
Expand Down
23 changes: 22 additions & 1 deletion pandas/tests/frame/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,8 @@ def test_setitem_string_column_numpy_dtype_raising(self):
def test_setitem_empty_df_duplicate_columns(self, using_copy_on_write):
# GH#38521
df = DataFrame(columns=["a", "b", "b"], dtype="float64")
df.loc[:, "a"] = list(range(2))
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.loc[:, "a"] = list(range(2))
expected = DataFrame(
[[0, np.nan, np.nan], [1, np.nan, np.nan]], columns=["a", "b", "b"]
)
Expand Down Expand Up @@ -1367,3 +1368,23 @@ def test_frame_setitem_empty_dataframe(self):
index=dti[:0],
)
tm.assert_frame_equal(df, expected)


def test_full_setter_loc_incompatible_dtype():
# https://github.com/pandas-dev/pandas/issues/55791
df = DataFrame({"a": [1, 2]})
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.loc[:, "a"] = True
expected = DataFrame({"a": [True, True]})
tm.assert_frame_equal(df, expected)

df = DataFrame({"a": [1, 2]})
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.loc[:, "a"] = {0: 3.5, 1: 4.5}
expected = DataFrame({"a": [3.5, 4.5]})
tm.assert_frame_equal(df, expected)

df = DataFrame({"a": [1, 2]})
df.loc[:, "a"] = {0: 3, 1: 4}
expected = DataFrame({"a": [3, 4]})
tm.assert_frame_equal(df, expected)
3 changes: 2 additions & 1 deletion pandas/tests/frame/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,8 @@ def test_categorical_replace_with_dict(self, replace_dict, final_data):
with pytest.raises(AssertionError, match=msg):
# ensure non-inplace call does not affect original
tm.assert_frame_equal(df, expected)
return_value = df.replace(replace_dict, 3, inplace=True)
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
return_value = df.replace(replace_dict, 3, inplace=True)
assert return_value is None
tm.assert_frame_equal(df, expected)

Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/frame/methods/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,8 @@ def test_update_with_different_dtype(self, using_copy_on_write):
# GH#3217
df = DataFrame({"a": [1, 3], "b": [np.nan, 2]})
df["c"] = np.nan
if using_copy_on_write:
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.update({"c": Series(["foo"], index=[0])})
else:
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df["c"].update(Series(["foo"], index=[0]))

expected = DataFrame({"a": [1, 3], "b": [np.nan, 2], "c": ["foo", np.nan]})
tm.assert_frame_equal(df, expected)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,7 @@ def test_dict_data_arrow_column_expansion(self, key_val, col_vals, col_type):
)
result = DataFrame({key_val: [1, 2]}, columns=cols)
expected = DataFrame([[1, np.nan], [2, np.nan]], columns=cols)
expected.iloc[:, 1] = expected.iloc[:, 1].astype(object)
expected[expected.columns[1]] = expected.iloc[:, 1].astype(object)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isetitem please

tm.assert_frame_equal(result, expected)


Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def f_1(grp):
with tm.assert_produces_warning(FutureWarning, match=msg):
result = df.groupby("A").apply(f_1)[["B"]]
e = expected.copy()
e.loc["Tiger"] = np.nan
e["B"] = [3, 5, float("nan")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changing? any reason for float('nan') instead of np.nan?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, it didn't need to change, thanks

tm.assert_frame_equal(result, e)

def f_2(grp):
Expand All @@ -211,7 +211,7 @@ def f_2(grp):
with tm.assert_produces_warning(FutureWarning, match=msg):
result = df.groupby("A").apply(f_2)[["B"]]
e = expected.copy()
e.loc["Pony"] = np.nan
e["B"] = [3, float("nan"), 0]
tm.assert_frame_equal(result, e)

# 5592 revisited, with datetimes
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ def test_iloc_setitem_frame_duplicate_columns_multiple_blocks(

# if the assigned values cannot be held by existing integer arrays,
# we cast
df.iloc[:, 0] = df.iloc[:, 0] + 0.5
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
df.iloc[:, 0] = df.iloc[:, 0] + 0.5
if not using_array_manager:
assert len(df._mgr.blocks) == 2

Expand Down Expand Up @@ -1460,6 +1461,7 @@ def test_iloc_setitem_pure_position_based(self):
def test_iloc_nullable_int64_size_1_nan(self):
# GH 31861
result = DataFrame({"a": ["test"], "b": [np.nan]})
result.loc[:, "b"] = result.loc[:, "b"].astype("Int64")
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
result.loc[:, "b"] = result.loc[:, "b"].astype("Int64")
expected = DataFrame({"a": ["test"], "b": array([NA], dtype="Int64")})
tm.assert_frame_equal(result, expected)
14 changes: 10 additions & 4 deletions pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,8 @@ def test_coercion_with_loc(self, expected):
start_data, expected_result, warn = expected

start_dataframe = DataFrame({"foo": start_data})
start_dataframe.loc[0, ["foo"]] = None
with tm.assert_produces_warning(warn, match="incompatible dtype"):
start_dataframe.loc[0, ["foo"]] = None

expected_dataframe = DataFrame({"foo": expected_result})
tm.assert_frame_equal(start_dataframe, expected_dataframe)
Expand All @@ -838,7 +839,8 @@ def test_coercion_with_setitem_and_dataframe(self, expected):
start_data, expected_result, warn = expected

start_dataframe = DataFrame({"foo": start_data})
start_dataframe[start_dataframe["foo"] == start_dataframe["foo"][0]] = None
with tm.assert_produces_warning(warn, match="incompatible dtype"):
start_dataframe[start_dataframe["foo"] == start_dataframe["foo"][0]] = None

expected_dataframe = DataFrame({"foo": expected_result})
tm.assert_frame_equal(start_dataframe, expected_dataframe)
Expand All @@ -848,7 +850,10 @@ def test_none_coercion_loc_and_dataframe(self, expected):
start_data, expected_result, warn = expected

start_dataframe = DataFrame({"foo": start_data})
start_dataframe.loc[start_dataframe["foo"] == start_dataframe["foo"][0]] = None
with tm.assert_produces_warning(warn, match="incompatible dtype"):
start_dataframe.loc[
start_dataframe["foo"] == start_dataframe["foo"][0]
] = None

expected_dataframe = DataFrame({"foo": expected_result})
tm.assert_frame_equal(start_dataframe, expected_dataframe)
Expand All @@ -862,7 +867,8 @@ def test_none_coercion_mixed_dtypes(self):
"d": ["a", "b", "c"],
}
)
start_dataframe.iloc[0] = None
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
start_dataframe.iloc[0] = None

exp = DataFrame(
{
Expand Down
Loading