@@ -112,7 +112,7 @@ def is_scalar(val: object) -> bint:
112
112
113
113
Parameters
114
114
----------
115
- val : input argument of any type
115
+ val : input argument of any type
116
116
This includes:
117
117
- numpy array scalar (e.g. np.int64 )
118
118
- Python builtin numerics
@@ -125,41 +125,41 @@ def is_scalar(val: object) -> bint:
125
125
- Interval
126
126
- DateOffset
127
127
- Fraction
128
- - Number.
128
+ - Number
129
129
130
130
Returns
131
131
-------
132
132
True if the given value is scalar , False otherwise.
133
133
134
134
Examples
135
135
--------
136
- >>> dt = pd.datetime.datetime(2018 ,10 ,3 )
136
+ >>> dt = pd.datetime.datetime(2018 , 10 , 3 )
137
137
>>> pd.is_scalar(dt )
138
138
True
139
139
140
- >>> pd.api.types.is_scalar([2,3])
140
+ >>> pd.api.types.is_scalar([2, 3])
141
141
False
142
142
143
- >>> pd.api.types.is_scalar({0:1,2:3})
143
+ >>> pd.api.types.is_scalar({0:1, 2:3})
144
144
False
145
145
146
- >>> pd.api.types.is_scalar((0,2))
146
+ >>> pd.api.types.is_scalar((0, 2))
147
147
False
148
148
149
149
pandas supports PEP 3141 numbers:
150
150
151
151
>>> from fractions import Fraction
152
- >>> pd.api.types.is_scalar(Fraction(3,5))
152
+ >>> pd.api.types.is_scalar(Fraction(3, 5))
153
153
True
154
154
155
- >>> from numbers import Number
155
+ >>> from numbers import Number
156
156
>>> pd.api.types.is_scalar(Number())
157
157
True
158
158
"""
159
159
160
160
return (cnp.PyArray_IsAnyScalar(val )
161
161
# As of numpy-1.9, PyArray_IsAnyScalar misses bytearrays on Py3.
162
- or isinstance(val ,(bytes ,Fraction ,Number ))
162
+ or isinstance(val ,(bytes , Fraction , Number ))
163
163
# We differ from numpy (as of 1.10), which claims that None is
164
164
# not scalar in np.isscalar().
165
165
or val is None
@@ -170,6 +170,7 @@ def is_scalar(val: object) -> bint:
170
170
or is_decimal(val )
171
171
or is_interval(val )
172
172
or util.is_offset_object(val ))
173
+
173
174
def item_from_zerodim(val: object ) -> object:
174
175
"""
175
176
If the value is a zerodim array , return the item it contains.
0 commit comments