19
19
import pytest
20
20
21
21
import pandas as pd
22
- from pandas import (
23
- Categorical ,
24
- CategoricalIndex ,
25
- Timestamp ,
26
- )
22
+ from pandas import Categorical
27
23
import pandas ._testing as tm
28
24
from pandas .api .types import CategoricalDtype
29
25
from pandas .tests .extension import base
@@ -93,7 +89,7 @@ class TestDtype(base.BaseDtypeTests):
93
89
class TestInterface (base .BaseInterfaceTests ):
94
90
@pytest .mark .xfail (reason = "Memory usage doesn't match" )
95
91
def test_memory_usage (self , data ):
96
- # Is this deliberate?
92
+ # TODO: Is this deliberate?
97
93
super ().test_memory_usage (data )
98
94
99
95
def test_contains (self , data , data_missing ):
@@ -194,51 +190,7 @@ def test_map(self, data, na_action):
194
190
195
191
196
192
class TestCasting (base .BaseCastingTests ):
197
- @pytest .mark .parametrize ("cls" , [Categorical , CategoricalIndex ])
198
- @pytest .mark .parametrize ("values" , [[1 , np .nan ], [Timestamp ("2000" ), pd .NaT ]])
199
- def test_cast_nan_to_int (self , cls , values ):
200
- # GH 28406
201
- s = cls (values )
202
-
203
- msg = "Cannot (cast|convert)"
204
- with pytest .raises ((ValueError , TypeError ), match = msg ):
205
- s .astype (int )
206
-
207
- @pytest .mark .parametrize (
208
- "expected" ,
209
- [
210
- pd .Series (["2019" , "2020" ], dtype = "datetime64[ns, UTC]" ),
211
- pd .Series ([0 , 0 ], dtype = "timedelta64[ns]" ),
212
- pd .Series ([pd .Period ("2019" ), pd .Period ("2020" )], dtype = "period[A-DEC]" ),
213
- pd .Series ([pd .Interval (0 , 1 ), pd .Interval (1 , 2 )], dtype = "interval" ),
214
- pd .Series ([1 , np .nan ], dtype = "Int64" ),
215
- ],
216
- )
217
- def test_cast_category_to_extension_dtype (self , expected ):
218
- # GH 28668
219
- result = expected .astype ("category" ).astype (expected .dtype )
220
-
221
- tm .assert_series_equal (result , expected )
222
-
223
- @pytest .mark .parametrize (
224
- "dtype, expected" ,
225
- [
226
- (
227
- "datetime64[ns]" ,
228
- np .array (["2015-01-01T00:00:00.000000000" ], dtype = "datetime64[ns]" ),
229
- ),
230
- (
231
- "datetime64[ns, MET]" ,
232
- pd .DatetimeIndex (
233
- [Timestamp ("2015-01-01 00:00:00+0100" , tz = "MET" )]
234
- ).array ,
235
- ),
236
- ],
237
- )
238
- def test_consistent_casting (self , dtype , expected ):
239
- # GH 28448
240
- result = Categorical (["2015-01-01" ]).astype (dtype )
241
- assert result == expected
193
+ pass
242
194
243
195
244
196
class TestArithmeticOps (base .BaseArithmeticOpsTests ):
@@ -274,19 +226,6 @@ def _compare_other(self, s, data, op, other):
274
226
else :
275
227
return super ()._compare_other (s , data , op , other )
276
228
277
- @pytest .mark .parametrize (
278
- "categories" ,
279
- [["a" , "b" ], [0 , 1 ], [Timestamp ("2019" ), Timestamp ("2020" )]],
280
- )
281
- def test_not_equal_with_na (self , categories ):
282
- # https://github.com/pandas-dev/pandas/issues/32276
283
- c1 = Categorical .from_codes ([- 1 , 0 ], categories = categories )
284
- c2 = Categorical .from_codes ([0 , 1 ], categories = categories )
285
-
286
- result = c1 != c2
287
-
288
- assert result .all ()
289
-
290
229
291
230
class TestParsing (base .BaseParsingTests ):
292
231
pass
@@ -301,12 +240,3 @@ def test_repr_2d(self, data):
301
240
302
241
res = repr (data .reshape (- 1 , 1 ))
303
242
assert res .count ("\n Categories" ) == 1
304
-
305
-
306
- def test_astype_category_readonly_mask_values ():
307
- # GH 53658
308
- df = pd .DataFrame ([0 , 1 , 2 ], dtype = "Int64" )
309
- df ._mgr .arrays [0 ]._mask .flags ["WRITEABLE" ] = False
310
- result = df .astype ("category" )
311
- expected = pd .DataFrame ([0 , 1 , 2 ], dtype = "Int64" ).astype ("category" )
312
- tm .assert_frame_equal (result , expected )
0 commit comments