MCPcopy Create free account
hub / github.com/dask/dask / _bind_property

Function _bind_property

dask/dataframe/accessor.py:25–44  ·  view source on GitHub ↗
(cls, pd_cls, attr, min_version=None)

Source from the content-addressed store, hash-verified

23
24
25def _bind_property(cls, pd_cls, attr, min_version=None):
26 def func(self):
27 return self._property_map(attr)
28
29 func.__name__ = attr
30 func.__qualname__ = f"{cls.__name__}.{attr}"
31 try:
32 # Attempt to determine the method we are wrapping
33 original_prop = getattr(pd_cls, attr)
34 if isinstance(original_prop, property):
35 method = original_prop.fget
36 elif isinstance(original_prop, functools.cached_property):
37 method = original_prop.func
38 else:
39 method = original_prop
40 func.__wrapped__ = method
41 except Exception:
42 # If we can't then no matter, the function still works.
43 pass
44 setattr(cls, attr, property(derived_from(pd_cls, version=min_version)(func)))
45
46
47def maybe_wrap_pandas(obj, x):

Callers 1

__init_subclass__Method · 0.90

Calls 1

derived_fromFunction · 0.90

Tested by

no test coverage detected