Skip to content

Commit

Permalink
set name in _from_mgr
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Oct 20, 2023
1 parent 4e64fbb commit 50584ad
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
IndexKeyFunc,
IndexLabel,
Level,
Manager,
MutableMappingT,
NaPosition,
NumpySorter,
Expand Down Expand Up @@ -346,7 +347,7 @@ class Series(base.IndexOpsMixin, NDFrame): # type: ignore[misc]
_typ = "series"
_HANDLED_TYPES = (Index, ExtensionArray, np.ndarray)

_name: Hashable = None
_name: Hashable
_metadata: list[str] = ["_name"]
_internal_names_set = {"index", "name"} | NDFrame._internal_names_set
_accessors = {"dt", "cat", "str", "sparse"}
Expand Down Expand Up @@ -574,6 +575,27 @@ def __init__(
self.name = name
self._set_axis(0, index)

@classmethod
def _from_mgr(cls, mgr: Manager, axes: list[Index]) -> Self:
"""
Construct a new Series from a Manager object and axes.
Parameters
----------
mgr : Manager
Must have the same ndim as cls.
axes : list[Index]
Notes
-----
The axes must match mgr.axes, but are required for future-proofing
in the event that axes are refactored out of the Manager objects.
"""
obj = cls.__new__(cls)
NDFrame.__init__(obj, mgr)
object.__setattr__(obj, "_name", None)
return obj

def _init_dict(
self, data, index: Index | None = None, dtype: DtypeObj | None = None
):
Expand Down

0 comments on commit 50584ad

Please sign in to comment.