@@ -90,6 +90,7 @@ def all_string_methods(request):
90
90
('unicode' if not PY3 else 'string' , [u ('a' ), np .nan , u ('c' )]),
91
91
('bytes' if PY3 else 'string' , [b'a' , np .nan , b'c' ]),
92
92
('empty' , [np .nan , np .nan , np .nan ]),
93
+ ('empty' , []),
93
94
('mixed-integer' , ['a' , np .nan , 2 ]),
94
95
('mixed' , ['a' , np .nan , 2.0 ])]
95
96
ids , _ = zip (* _all_allowed_skipna_inferred_dtypes ) # use inferred type as id
@@ -126,12 +127,13 @@ def all_allowed_skipna_inferred_dtypes(request):
126
127
('integer' , [1 , np .nan , 2 ]),
127
128
('mixed-integer-float' , [1 , np .nan , 2.0 ]),
128
129
('decimal' , [Decimal (1 ), np .nan , Decimal (2 )]),
129
- # ('complex', [1 + 1j, np.nan, 2 + 2j]),
130
130
('boolean' , [True , np .nan , False ]),
131
131
('datetime64' , [np .datetime64 ('2013-01-01' ), np .nan ,
132
132
np .datetime64 ('2018-01-01' )]),
133
133
('datetime' , [Timestamp ('20130101' ), np .nan , Timestamp ('20180101' )]),
134
134
('date' , [date (2013 , 1 , 1 ), np .nan , date (2018 , 1 , 1 )]),
135
+ # The following two dtypes are commented out due to GH 23554
136
+ # ('complex', [1 + 1j, np.nan, 2 + 2j]),
135
137
# ('timedelta64', [np.timedelta64(1, 'D'),
136
138
# np.nan, np.timedelta64(2, 'D')]),
137
139
('timedelta' , [timedelta (1 ), np .nan , timedelta (2 )]),
@@ -198,7 +200,7 @@ def test_api_per_dtype(self, box, dtype, all_skipna_inferred_dtypes):
198
200
if dtype == 'category' and inferred_dtype in ['period' , 'interval' ]:
199
201
pytest .xfail (reason = 'Conversion to numpy array fails because '
200
202
'the ._values-attribute is not a numpy array for '
201
- 'PeriodIndex/IntervalIndex ; see GH 23553' )
203
+ 'PeriodArray/IntervalArray ; see GH 23553' )
202
204
203
205
types_passing_constructor = ['string' , 'unicode' , 'empty' ,
204
206
'bytes' , 'mixed' , 'mixed-integer' ]
@@ -237,23 +239,26 @@ def test_api_per_method(self, box, dtype,
237
239
and inferred_dtype != 'bytes' ):
238
240
pytest .xfail (reason = 'Method not nan-safe on Index; see GH 23558' )
239
241
if (method_name == 'get_dummies' and box == Index
240
- and inferred_dtype == 'empty' and dtype == object ):
241
- pytest .xfail (reason = 'Need to fortify get_dummies corner case' )
242
+ and inferred_dtype == 'empty' and (dtype == object
243
+ or values .size == 0 )):
244
+ pytest .xfail (reason = 'Need to fortify get_dummies corner cases' )
242
245
243
246
t = box (values , dtype = dtype ) # explicit dtype to avoid casting
244
247
method = getattr (t .str , method_name )
245
248
246
249
bytes_allowed = method_name in ['encode' , 'decode' , 'len' ]
247
250
# as of v0.23.4, all methods except 'cat' are very lenient with the
248
251
# allowed data types, just returning NaN for entries that error.
249
- # This could be changed with an 'errors'-kwarg to the `str`-accessor.
252
+ # This could be changed with an 'errors'-kwarg to the `str`-accessor,
253
+ # see discussion in GH 13877
250
254
mixed_allowed = method_name not in ['cat' ]
251
255
252
256
allowed_types = (['string' , 'unicode' , 'empty' ]
253
257
+ ['bytes' ] * bytes_allowed
254
258
+ ['mixed' , 'mixed-integer' ] * mixed_allowed )
255
259
256
260
if inferred_dtype in allowed_types :
261
+ # i.a. GH 23555, GH 23556
257
262
method (* minimal_args ) # works!
258
263
else :
259
264
# GH 23011, GH 23163
0 commit comments