Skip to content

Commit 03cb788

Browse files
committed
Add fixture case for completely empty "values"; some more xrefs
1 parent e2cb4db commit 03cb788

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pandas/tests/test_strings.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def all_string_methods(request):
9090
('unicode' if not PY3 else 'string', [u('a'), np.nan, u('c')]),
9191
('bytes' if PY3 else 'string', [b'a', np.nan, b'c']),
9292
('empty', [np.nan, np.nan, np.nan]),
93+
('empty', []),
9394
('mixed-integer', ['a', np.nan, 2]),
9495
('mixed', ['a', np.nan, 2.0])]
9596
ids, _ = zip(*_all_allowed_skipna_inferred_dtypes) # use inferred type as id
@@ -126,12 +127,13 @@ def all_allowed_skipna_inferred_dtypes(request):
126127
('integer', [1, np.nan, 2]),
127128
('mixed-integer-float', [1, np.nan, 2.0]),
128129
('decimal', [Decimal(1), np.nan, Decimal(2)]),
129-
# ('complex', [1 + 1j, np.nan, 2 + 2j]),
130130
('boolean', [True, np.nan, False]),
131131
('datetime64', [np.datetime64('2013-01-01'), np.nan,
132132
np.datetime64('2018-01-01')]),
133133
('datetime', [Timestamp('20130101'), np.nan, Timestamp('20180101')]),
134134
('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]),
135137
# ('timedelta64', [np.timedelta64(1, 'D'),
136138
# np.nan, np.timedelta64(2, 'D')]),
137139
('timedelta', [timedelta(1), np.nan, timedelta(2)]),
@@ -198,7 +200,7 @@ def test_api_per_dtype(self, box, dtype, all_skipna_inferred_dtypes):
198200
if dtype == 'category' and inferred_dtype in ['period', 'interval']:
199201
pytest.xfail(reason='Conversion to numpy array fails because '
200202
'the ._values-attribute is not a numpy array for '
201-
'PeriodIndex/IntervalIndex; see GH 23553')
203+
'PeriodArray/IntervalArray; see GH 23553')
202204

203205
types_passing_constructor = ['string', 'unicode', 'empty',
204206
'bytes', 'mixed', 'mixed-integer']
@@ -237,23 +239,26 @@ def test_api_per_method(self, box, dtype,
237239
and inferred_dtype != 'bytes'):
238240
pytest.xfail(reason='Method not nan-safe on Index; see GH 23558')
239241
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')
242245

243246
t = box(values, dtype=dtype) # explicit dtype to avoid casting
244247
method = getattr(t.str, method_name)
245248

246249
bytes_allowed = method_name in ['encode', 'decode', 'len']
247250
# as of v0.23.4, all methods except 'cat' are very lenient with the
248251
# 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
250254
mixed_allowed = method_name not in ['cat']
251255

252256
allowed_types = (['string', 'unicode', 'empty']
253257
+ ['bytes'] * bytes_allowed
254258
+ ['mixed', 'mixed-integer'] * mixed_allowed)
255259

256260
if inferred_dtype in allowed_types:
261+
# i.a. GH 23555, GH 23556
257262
method(*minimal_args) # works!
258263
else:
259264
# GH 23011, GH 23163

0 commit comments

Comments
 (0)