Skip to content

Commit 36e9f68

Browse files
committed
CLN: revert unrelated allow_duplicates and cols_droplevel changes
1 parent 3b73369 commit 36e9f68

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

pandas/core/frame.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,14 +4703,11 @@ def _set_item_frame_value(self, key, value: DataFrame) -> None:
47034703
if (
47044704
not isinstance(cols_droplevel, MultiIndex)
47054705
and is_string_dtype(cols_droplevel.dtype)
4706-
and (cols_droplevel == "").all()
4706+
and not cols_droplevel.any()
47074707
):
47084708
# if cols_droplevel contains only empty strings,
47094709
# value.reindex(cols_droplevel, axis=1) would be full of NaNs
47104710
# see GH#62518 and GH#61841
4711-
# Note: use (== "").all() rather than not .any() to avoid
4712-
# triggering on falsy-but-non-empty values such as integer 0
4713-
# (GH#65118).
47144711
return
47154712
if len(cols_droplevel) and not cols_droplevel.equals(value.columns):
47164713
value = value.reindex(cols_droplevel, axis=1)
@@ -5496,7 +5493,7 @@ def insert(
54965493
loc: int,
54975494
column: Hashable,
54985495
value: object,
5499-
allow_duplicates: bool | lib.NoDefault = lib.no_default,
5496+
allow_duplicates: bool = False,
55005497
) -> None:
55015498
"""
55025499
Insert column into DataFrame at specified location.
@@ -5512,7 +5509,7 @@ def insert(
55125509
Label of the inserted column.
55135510
value : Scalar, Series, or array-like
55145511
Content of the inserted column.
5515-
allow_duplicates : bool, optional, default lib.no_default
5512+
allow_duplicates : bool, default False
55165513
Allow duplicate column labels to be created.
55175514

55185515
See Also
@@ -5545,8 +5542,6 @@ def insert(
55455542
0 NaN 100 1 99 3
55465543
1 5.0 100 2 99 4
55475544
"""
5548-
if allow_duplicates is lib.no_default:
5549-
allow_duplicates = False
55505545
if allow_duplicates and not self.flags.allows_duplicate_labels:
55515546
raise ValueError(
55525547
"Cannot specify 'allow_duplicates=True' when "
@@ -6988,7 +6983,7 @@ def reset_index(
69886983
inplace: Literal[False] = ...,
69896984
col_level: Hashable = ...,
69906985
col_fill: Hashable = ...,
6991-
allow_duplicates: bool | lib.NoDefault = ...,
6986+
allow_duplicates: bool = ...,
69926987
names: Hashable | Sequence[Hashable] | None = None,
69936988
) -> DataFrame: ...
69946989

@@ -7001,7 +6996,7 @@ def reset_index(
70016996
inplace: Literal[True],
70026997
col_level: Hashable = ...,
70036998
col_fill: Hashable = ...,
7004-
allow_duplicates: bool | lib.NoDefault = ...,
6999+
allow_duplicates: bool = ...,
70057000
names: Hashable | Sequence[Hashable] | None = None,
70067001
) -> None: ...
70077002

@@ -7014,7 +7009,7 @@ def reset_index(
70147009
inplace: bool = ...,
70157010
col_level: Hashable = ...,
70167011
col_fill: Hashable = ...,
7017-
allow_duplicates: bool | lib.NoDefault = ...,
7012+
allow_duplicates: bool = ...,
70187013
names: Hashable | Sequence[Hashable] | None = None,
70197014
) -> DataFrame | None: ...
70207015

@@ -7026,7 +7021,7 @@ def reset_index(
70267021
inplace: bool = False,
70277022
col_level: Hashable = 0,
70287023
col_fill: Hashable = "",
7029-
allow_duplicates: bool | lib.NoDefault = lib.no_default,
7024+
allow_duplicates: bool = False,
70307025
names: Hashable | Sequence[Hashable] | None = None,
70317026
) -> DataFrame | None:
70327027
"""
@@ -7053,7 +7048,7 @@ def reset_index(
70537048
col_fill : object, default ''
70547049
If the columns have multiple levels, determines how the other
70557050
levels are named. If None then the index name is repeated.
7056-
allow_duplicates : bool, optional, default lib.no_default
7051+
allow_duplicates : bool, default False
70577052
Allow duplicate column labels to be created.
70587053
names : int, str or 1-dimensional list, default None
70597054
Using the given string, rename the DataFrame column which contains the
@@ -7193,8 +7188,7 @@ class max type
71937188
new_obj = self
71947189
else:
71957190
new_obj = self.copy(deep=False)
7196-
if allow_duplicates is not lib.no_default:
7197-
allow_duplicates = validate_bool_kwarg(allow_duplicates, "allow_duplicates")
7191+
allow_duplicates = validate_bool_kwarg(allow_duplicates, "allow_duplicates")
71987192

71997193
new_index = default_index(len(new_obj))
72007194
if level is not None:

0 commit comments

Comments
 (0)