Skip to content

Commit f402fb4

Browse files
committed
TYP: Add FrameORSeries to NDFrame
1 parent 9871bdd commit f402fb4

File tree

3 files changed

+103
-61
lines changed

3 files changed

+103
-61
lines changed

pandas/core/base.py

+12
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
from pandas.core.construction import create_series_with_explicit_dtype
3838
import pandas.core.nanops as nanops
3939

40+
41+
from pandas._typing import T
42+
43+
4044
_shared_docs: Dict[str, str] = dict()
4145
_indexops_doc_kwargs = dict(
4246
klass="IndexOpsMixin",
@@ -87,6 +91,14 @@ def __sizeof__(self):
8791
# object's 'sizeof'
8892
return super().__sizeof__()
8993

94+
def _ensure_type(self: T, obj) -> T:
95+
"""Ensure that an object has same type as self.
96+
97+
Used by type checkers.
98+
"""
99+
assert isinstance(obj, type(self)), type(obj)
100+
return obj
101+
90102

91103
class NoNewAttributesMixin:
92104
"""Mixin which prevents adding new attributes.

0 commit comments

Comments
 (0)