Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ Indexing
- Bug in :meth:`CategoricalIndex.get_indexer` when index contains ``NaN`` values, resulting in elements that are in target but not present in the index to be mapped to the index of the NaN element, instead of -1 (:issue:`45361`)
- Bug in setting large integer values into :class:`Series` with ``float32`` or ``float16`` dtype incorrectly altering these values instead of coercing to ``float64`` dtype (:issue:`45844`)
- Bug in :meth:`Series.asof` and :meth:`DataFrame.asof` incorrectly casting bool-dtype results to ``float64`` dtype (:issue:`16063`)
- Bug in :meth:`NDFrame.xs`, :meth:`DataFrame.iterrows`, :meth:`DataFrame.loc` and :meth:`DataFrame.iloc` not always propagating metadata (:issue:`28283`)
-

Missing
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ def iterrows(self) -> Iterable[tuple[Hashable, Series]]:
columns = self.columns
klass = self._constructor_sliced
for k, v in zip(self.index, self.values):
s = klass(v, index=columns, name=k)
s = klass(v, index=columns, name=k).__finalize__(self)
yield k, s

def itertuples(
Expand Down Expand Up @@ -3453,7 +3453,7 @@ def _ixs(self, i: int, axis: int = 0):
index=self.columns,
name=self.index[i],
dtype=new_values.dtype,
)
).__finalize__(self)
result._set_is_copy(self, copy=copy)
return result

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3816,7 +3816,7 @@ class animal locomotion
index=self.columns,
name=self.index[loc],
dtype=new_values.dtype,
)
).__finalize__(self)
elif is_scalar(loc):
result = self.iloc[:, slice(loc, loc + 1)]
elif axis == 1:
Expand Down
9 changes: 2 additions & 7 deletions pandas/tests/generic/test_duplicate_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def test_binops(self, func, other, frame):
assert df.flags.allows_duplicate_labels is False
assert func(df).flags.allows_duplicate_labels is False

@not_implemented
def test_preserve_getitem(self):
df = pd.DataFrame({"A": [1, 2]}).set_flags(allows_duplicate_labels=False)
assert df[["A"]].flags.allows_duplicate_labels is False
Expand Down Expand Up @@ -306,15 +305,11 @@ def test_series_raises(self):
(operator.itemgetter(["A", "A"]), None),
# loc
(operator.itemgetter(["a", "a"]), "loc"),
pytest.param(
operator.itemgetter(("a", ["A", "A"])), "loc", marks=not_implemented
),
pytest.param(operator.itemgetter(("a", ["A", "A"])), "loc"),
(operator.itemgetter((["a", "a"], "A")), "loc"),
# iloc
(operator.itemgetter([0, 0]), "iloc"),
pytest.param(
operator.itemgetter((0, [0, 0])), "iloc", marks=not_implemented
),
pytest.param(operator.itemgetter((0, [0, 0])), "iloc"),
pytest.param(operator.itemgetter(([0, 0], 0)), "iloc"),
],
)
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/generic/test_finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@
frame_data,
operator.methodcaller("quantile", numeric_only=True),
),
marks=not_implemented_mark,
),
pytest.param(
(
Expand All @@ -259,10 +258,9 @@
pytest.param(
(
pd.DataFrame,
frame_data,
operator.methodcaller("quantile", numeric_only=True),
({"A": [pd.Timedelta(days=1), pd.Timedelta(days=2)]},),
operator.methodcaller("quantile", numeric_only=False),
),
marks=not_implemented_mark,
),
(
pd.DataFrame,
Expand Down