Skip to content
Open
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Bug fixes
- Fixed :class:`ArrowDtype` string arithmetic for addition between ``string`` and ``large_string`` typed arrays (:issue:`65220`)
- Fixed a bug in adding missing values (e.g. :attr:`NA`) to a pyarrow-backed string array or Series
raising an error instead of propagating the missing value (:issue:`64968`)
- Fixed a bug in :meth:`DataFrame.from_dict` where rows corresponding to an empty :class:`Series` or ``dict`` are dropped when ``orient='index'`` (:issue:`62775`)
- Fixed a bug in :meth:`Series.rank` with period dtype and missing values, always sorting missing values at the top, regardless of the ``na_option`` value (:issue:`64976`)
- Fixed a bug in reading files with a chained URL scheme (e.g. ``tar://``) with the latest version of ``fsspec`` (:issue:`65462`).
- Fixed a hang in :meth:`Series.str.replace` for PyArrow-backed string data when replacing an empty pattern; behavior now matches Python's ``str.replace`` (:issue:`64941`).
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -19014,7 +19014,7 @@ def values(self) -> np.ndarray:


def _from_nested_dict(
data: Mapping[HashableT, Mapping[HashableT2, T]],
data: Mapping[HashableT, Mapping[HashableT2, T | None]],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe with my suggestion, all of these code changes are no longer necessary and can be reverted. Can you confirm.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good morning @rhshadrach, unfortunately the suggestion doesn't resolve the issue. I pushed the reverted changes but retained the test.
image
image

) -> collections.defaultdict[HashableT2, dict[HashableT, T]]:
new_data: collections.defaultdict[HashableT2, dict[HashableT, T]] = (
collections.defaultdict(dict)
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/frame/constructors/test_from_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ def test_constructor_single_row(self):
).reindex(result.index)
tm.assert_frame_equal(result, expected)

def test_from_nested_dict_series_with_empty_series(self):
data = {"good": Series({"a": 1, "b": 2}), "blank": Series()}

result = DataFrame.from_dict(data, orient="index")
expected = DataFrame(
{
"a": {"good": 1.0, "blank": np.nan},
"b": {"good": 2.0, "blank": np.nan},
}
)
tm.assert_frame_equal(result, expected)

def test_constructor_list_of_series(self):
data = [
OrderedDict([["a", 1.5], ["b", 3.0], ["c", 4.0]]),
Expand Down
Loading