@@ -319,29 +319,32 @@ def test_multiindex_dt_with_nan(self):
319
319
expected = Series (["a" , "b" , "c" , "d" ], name = ("sub" , np .nan ))
320
320
tm .assert_series_equal (result , expected )
321
321
322
- # Ignore deprecation raised by old versions of pyarrow. Already fixed in
323
- # newer versions
324
322
@pytest .mark .filterwarnings ("ignore:Passing a BlockManager:DeprecationWarning" )
325
323
def test_multiindex_with_pyarrow_categorical (self ):
326
324
# GH#53051
327
-
328
325
pa = pytest .importorskip ("pyarrow" )
329
326
330
- # Create dataframe with categorical column
331
- df = DataFrame (
332
- {"string_column" : ["A" , "B" , "C" ], "number_column" : [1 , 2 , 3 ]}
333
- ).astype ({"string_column" : "category" , "number_column" : "float32" })
334
-
335
- # Convert dataframe to pyarrow backend
336
- df = df .astype (
337
- {
338
- "string_column" : ArrowDtype (pa .dictionary (pa .int32 (), pa .string ())),
339
- "number_column" : "float[pyarrow]" ,
340
- }
327
+ df = (
328
+ DataFrame ({"string_column" : ["A" , "B" , "C" ], "number_column" : [1 , 2 , 3 ]})
329
+ .astype ({"string_column" : "category" , "number_column" : "float32" })
330
+ .astype (
331
+ {
332
+ "string_column" : ArrowDtype (pa .dictionary (pa .int32 (), pa .string ())),
333
+ "number_column" : "float[pyarrow]" ,
334
+ }
335
+ )
341
336
)
342
337
343
- # Check that index can be set
344
- df .set_index (["string_column" , "number_column" ])
338
+ df = df .set_index (["string_column" , "number_column" ])
339
+
340
+ df_expected = DataFrame (
341
+ index = MultiIndex .from_arrays (
342
+ [["A" , "B" , "C" ], [1 , 2 , 3 ]], names = ["string_column" , "number_column" ]
343
+ )
344
+ )
345
+ tm .assert_frame_equal (
346
+ df , df_expected , check_dtype = False , check_column_type = False
347
+ )
345
348
346
349
347
350
class TestSorted :
0 commit comments