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

Function is_scalar

dask/dataframe/utils.py:46–59  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

44
45
46def is_scalar(x):
47 # np.isscalar does not work for some pandas scalars, for example pd.NA
48 if isinstance(x, (Sequence, Iterable)) and not isinstance(x, str):
49 return False
50 elif hasattr(x, "dtype"):
51 return isinstance(x, np.ScalarType)
52 if isinstance(x, dict):
53 return False
54 if isinstance(x, (str, int)) or x is None:
55 return True
56
57 from dask.dataframe.dask_expr._expr import Expr
58
59 return not isinstance(x, Expr)
60
61
62def is_integer_na_dtype(t):

Callers 15

apply_and_enforceFunction · 0.90
specMethod · 0.90
groupby_get_groupFunction · 0.90
_contains_index_nameFunction · 0.90
_meta_apply_transformFunction · 0.90
__getitem__Method · 0.90
_divisionsMethod · 0.90
_simplify_downMethod · 0.90
_metaMethod · 0.90
aggregateMethod · 0.90
__getitem__Method · 0.90

Calls

no outgoing calls

Tested by 2

test_expr_is_scalarFunction · 0.72
assert_near_timedeltasFunction · 0.68