11import numpy as np
22import pytest
33
4- from pandas ._config import using_string_dtype
5-
64import pandas as pd
75from pandas import (
86 DataFrame ,
@@ -326,7 +324,6 @@ def test_quantile_multi_empty(self, interp_method):
326324 )
327325 tm .assert_frame_equal (result , expected )
328326
329- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
330327 def test_quantile_datetime (self , unit ):
331328 dti = pd .to_datetime (["2010" , "2011" ]).as_unit (unit )
332329 df = DataFrame ({"a" : dti , "b" : [0 , 5 ]})
@@ -373,14 +370,13 @@ def test_quantile_datetime(self, unit):
373370
374371 # empty when numeric_only=True
375372 result = df [["a" , "c" ]].quantile (0.5 , numeric_only = True )
376- expected = Series ([], index = [] , dtype = np .float64 , name = 0.5 )
373+ expected = Series ([], index = Index ([], dtype = "str" ) , dtype = np .float64 , name = 0.5 )
377374 tm .assert_series_equal (result , expected )
378375
379376 result = df [["a" , "c" ]].quantile ([0.5 ], numeric_only = True )
380- expected = DataFrame (index = [0.5 ], columns = [] )
377+ expected = DataFrame (index = [0.5 ], columns = Index ([], dtype = "str" ) )
381378 tm .assert_frame_equal (result , expected )
382379
383- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
384380 @pytest .mark .parametrize (
385381 "dtype" ,
386382 [
@@ -398,7 +394,7 @@ def test_quantile_dt64_empty(self, dtype, interp_method):
398394 res = df .quantile (
399395 0.5 , axis = 1 , numeric_only = False , interpolation = interpolation , method = method
400396 )
401- expected = Series ([], index = [] , name = 0.5 , dtype = dtype )
397+ expected = Series ([], index = Index ([], dtype = "str" ) , name = 0.5 , dtype = dtype )
402398 tm .assert_series_equal (res , expected )
403399
404400 # no columns in result, so no dtype preservation
@@ -409,7 +405,7 @@ def test_quantile_dt64_empty(self, dtype, interp_method):
409405 interpolation = interpolation ,
410406 method = method ,
411407 )
412- expected = DataFrame (index = [0.5 ], columns = [] )
408+ expected = DataFrame (index = [0.5 ], columns = Index ([], dtype = "str" ) )
413409 tm .assert_frame_equal (res , expected )
414410
415411 @pytest .mark .parametrize ("invalid" , [- 1 , 2 , [0.5 , - 1 ], [0.5 , 2 ]])
@@ -645,7 +641,6 @@ def test_quantile_nat(self, interp_method, unit):
645641 )
646642 tm .assert_frame_equal (res , exp )
647643
648- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
649644 def test_quantile_empty_no_rows_floats (self , interp_method ):
650645 interpolation , method = interp_method
651646
@@ -660,11 +655,11 @@ def test_quantile_empty_no_rows_floats(self, interp_method):
660655 tm .assert_frame_equal (res , exp )
661656
662657 res = df .quantile (0.5 , axis = 1 , interpolation = interpolation , method = method )
663- exp = Series ([], index = [] , dtype = "float64" , name = 0.5 )
658+ exp = Series ([], index = Index ([], dtype = "str" ) , dtype = "float64" , name = 0.5 )
664659 tm .assert_series_equal (res , exp )
665660
666661 res = df .quantile ([0.5 ], axis = 1 , interpolation = interpolation , method = method )
667- exp = DataFrame (columns = [] , index = [0.5 ])
662+ exp = DataFrame (columns = Index ([], dtype = "str" ) , index = [0.5 ])
668663 tm .assert_frame_equal (res , exp )
669664
670665 def test_quantile_empty_no_rows_ints (self , interp_method ):
@@ -874,7 +869,6 @@ def test_quantile_ea_scalar(self, request, obj, index):
874869 else :
875870 tm .assert_series_equal (result , expected )
876871
877- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False )
878872 @pytest .mark .parametrize (
879873 "dtype, expected_data, expected_index, axis" ,
880874 [
@@ -889,11 +883,13 @@ def test_empty_numeric(self, dtype, expected_data, expected_index, axis):
889883 df = DataFrame (columns = ["a" , "b" ], dtype = dtype )
890884 result = df .quantile (0.5 , axis = axis )
891885 expected = Series (
892- expected_data , name = 0.5 , index = Index (expected_index ), dtype = "float64"
886+ expected_data ,
887+ name = 0.5 ,
888+ index = Index (expected_index , dtype = "str" ),
889+ dtype = "float64" ,
893890 )
894891 tm .assert_series_equal (result , expected )
895892
896- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False )
897893 @pytest .mark .parametrize (
898894 "dtype, expected_data, expected_index, axis, expected_dtype" ,
899895 [
@@ -908,11 +904,13 @@ def test_empty_datelike(
908904 df = DataFrame (columns = ["a" , "b" ], dtype = dtype )
909905 result = df .quantile (0.5 , axis = axis , numeric_only = False )
910906 expected = Series (
911- expected_data , name = 0.5 , index = Index (expected_index ), dtype = expected_dtype
907+ expected_data ,
908+ name = 0.5 ,
909+ index = Index (expected_index , dtype = "str" ),
910+ dtype = expected_dtype ,
912911 )
913912 tm .assert_series_equal (result , expected )
914913
915- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False )
916914 @pytest .mark .parametrize (
917915 "expected_data, expected_index, axis" ,
918916 [
@@ -931,7 +929,10 @@ def test_datelike_numeric_only(self, expected_data, expected_index, axis):
931929 )
932930 result = df [["a" , "c" ]].quantile (0.5 , axis = axis , numeric_only = True )
933931 expected = Series (
934- expected_data , name = 0.5 , index = Index (expected_index ), dtype = np .float64
932+ expected_data ,
933+ name = 0.5 ,
934+ index = Index (expected_index , dtype = "str" if axis == 0 else "int64" ),
935+ dtype = np .float64 ,
935936 )
936937 tm .assert_series_equal (result , expected )
937938
0 commit comments