Skip to content

Commit 341a719

Browse files
authored
BUG: Too aggressive typing in NDFrame.align (#31788)
1 parent ccc6923 commit 341a719

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

doc/source/whatsnew/v1.0.2.rst

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Fixed regressions
1616
~~~~~~~~~~~~~~~~~
1717

1818
- Fixed regression in :meth:`DataFrame.to_excel` when ``columns`` kwarg is passed (:issue:`31677`)
19+
- Fixed regression in :meth:`Series.align` when ``other`` is a DataFrame and ``method`` is not None (:issue:`31785`)
1920
-
2021

2122
.. ---------------------------------------------------------------------------

pandas/core/generic.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8360,9 +8360,7 @@ def _align_frame(
83608360
left = self._ensure_type(
83618361
left.fillna(method=method, axis=fill_axis, limit=limit)
83628362
)
8363-
right = self._ensure_type(
8364-
right.fillna(method=method, axis=fill_axis, limit=limit)
8365-
)
8363+
right = right.fillna(method=method, axis=fill_axis, limit=limit)
83668364

83678365
# if DatetimeIndex have different tz, convert to UTC
83688366
if is_datetime64tz_dtype(left.index):

pandas/tests/series/indexing/test_alter_index.py

+11
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ def test_align_multiindex():
153153
tm.assert_series_equal(expr, res2l)
154154

155155

156+
@pytest.mark.parametrize("method", ["backfill", "bfill", "pad", "ffill", None])
157+
def test_align_method(method):
158+
# GH31788
159+
ser = pd.Series(range(3), index=range(3))
160+
df = pd.DataFrame(0.0, index=range(3), columns=range(3))
161+
162+
result_ser, result_df = ser.align(df, method=method)
163+
tm.assert_series_equal(result_ser, ser)
164+
tm.assert_frame_equal(result_df, df)
165+
166+
156167
def test_reindex(datetime_series, string_series):
157168
identity = string_series.reindex(string_series.index)
158169

0 commit comments

Comments
 (0)