Skip to content

Commit

Permalink
Merge branch 'main' into issue#57111_2
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-d-murphy authored Jan 31, 2024
2 parents 40fce8a + b41ea09 commit 3c52d12
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Fixed regressions
- Fixed regression in :func:`merge_ordered` raising ``TypeError`` for ``fill_method="ffill"`` and ``how="left"`` (:issue:`57010`)
- Fixed regression in :func:`wide_to_long` raising an ``AttributeError`` for string columns (:issue:`57066`)
- Fixed regression in :meth:`DataFrame.loc` raising ``IndexError`` for non-unique, masked dtype indexes where result has more than 10,000 rows (:issue:`57027`)
- Fixed regression in :meth:`DataFrame.to_dict` with ``orient='list'`` and datetime or timedelta types returning integers (:issue:`54824`)
- Fixed regression in :meth:`DataFrameGroupBy.idxmin`, :meth:`DataFrameGroupBy.idxmax`, :meth:`SeriesGroupBy.idxmin`, :meth:`SeriesGroupBy.idxmax` ignoring the ``skipna`` argument (:issue:`57040`)
- Fixed regression in :meth:`DataFrameGroupBy.idxmin`, :meth:`DataFrameGroupBy.idxmax`, :meth:`SeriesGroupBy.idxmin`, :meth:`SeriesGroupBy.idxmax` where values containing the minimum or maximum value for the dtype could produce incorrect results (:issue:`57040`)
- Fixed regression in :meth:`Index.join` raising ``TypeError`` when joining an empty index to a non-empty index containing mixed dtype values (:issue:`57048`)
Expand Down
3 changes: 2 additions & 1 deletion pandas/_libs/tslibs/tzconversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ cdef ndarray[int64_t] _get_dst_hours(
ndarray[uint8_t, cast=True] mismatch
ndarray[int64_t] delta, dst_hours
ndarray[intp_t] switch_idxs, trans_idx, grp, a_idx, b_idx, one_diff
list trans_grp
# TODO: Can uncomment when numpy >=2 is the minimum
# tuple trans_grp
intp_t switch_idx
int64_t left, right

Expand Down
8 changes: 2 additions & 6 deletions pandas/core/methods/to_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,9 @@ def to_dict(
return into_c(
(
k,
list(
map(
maybe_box_native, v.to_numpy(na_value=box_na_values[i]).tolist()
)
)
list(map(maybe_box_native, v.to_numpy(na_value=box_na_values[i])))
if i in object_dtype_indices_as_set
else v.to_numpy().tolist(),
else list(map(maybe_box_native, v.to_numpy())),
)
for i, (k, v) in enumerate(df.items())
)
Expand Down
14 changes: 14 additions & 0 deletions pandas/tests/frame/methods/test_to_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
NA,
DataFrame,
Index,
Interval,
MultiIndex,
Period,
Series,
Timedelta,
Timestamp,
)
import pandas._testing as tm
Expand Down Expand Up @@ -519,3 +522,14 @@ def test_to_dict_pos_args_deprecation(self):
)
with tm.assert_produces_warning(FutureWarning, match=msg):
df.to_dict("records", {})


@pytest.mark.parametrize(
"val", [Timestamp(2020, 1, 1), Timedelta(1), Period("2020"), Interval(1, 2)]
)
def test_to_dict_list_pd_scalars(val):
# GH 54824
df = DataFrame({"a": [val]})
result = df.to_dict(orient="list")
expected = {"a": [val]}
assert result == expected

0 comments on commit 3c52d12

Please sign in to comment.