2121 to_datetime ,
2222)
2323import pandas ._testing as tm
24+ from pandas .util .version import Version
2425
2526
2627def tests_value_counts_index_names_category_column ():
@@ -244,8 +245,18 @@ def test_bad_subset(education_df):
244245 gp .value_counts (subset = ["country" ])
245246
246247
247- def test_basic (education_df ):
248+ def test_basic (education_df , request ):
248249 # gh43564
250+ if Version (np .__version__ ) >= Version ("1.25" ):
251+ request .node .add_marker (
252+ pytest .mark .xfail (
253+ reason = (
254+ "pandas default unstable sorting of duplicates"
255+ "issue with numpy>=1.25 with AVX instructions"
256+ ),
257+ strict = False ,
258+ )
259+ )
249260 result = education_df .groupby ("country" )[["gender" , "education" ]].value_counts (
250261 normalize = True
251262 )
@@ -283,7 +294,7 @@ def _frame_value_counts(df, keys, normalize, sort, ascending):
283294@pytest .mark .parametrize ("as_index" , [True , False ])
284295@pytest .mark .parametrize ("frame" , [True , False ])
285296def test_against_frame_and_seriesgroupby (
286- education_df , groupby , normalize , name , sort , ascending , as_index , frame
297+ education_df , groupby , normalize , name , sort , ascending , as_index , frame , request
287298):
288299 # test all parameters:
289300 # - Use column, array or function as by= parameter
@@ -293,6 +304,16 @@ def test_against_frame_and_seriesgroupby(
293304 # - 3-way compare against:
294305 # - apply with :meth:`~DataFrame.value_counts`
295306 # - `~SeriesGroupBy.value_counts`
307+ if Version (np .__version__ ) >= Version ("1.25" ) and frame and sort and normalize :
308+ request .node .add_marker (
309+ pytest .mark .xfail (
310+ reason = (
311+ "pandas default unstable sorting of duplicates"
312+ "issue with numpy>=1.25 with AVX instructions"
313+ ),
314+ strict = False ,
315+ )
316+ )
296317 by = {
297318 "column" : "country" ,
298319 "array" : education_df ["country" ].values ,
@@ -454,8 +475,18 @@ def nulls_df():
454475 ],
455476)
456477def test_dropna_combinations (
457- nulls_df , group_dropna , count_dropna , expected_rows , expected_values
478+ nulls_df , group_dropna , count_dropna , expected_rows , expected_values , request
458479):
480+ if Version (np .__version__ ) >= Version ("1.25" ) and not group_dropna :
481+ request .node .add_marker (
482+ pytest .mark .xfail (
483+ reason = (
484+ "pandas default unstable sorting of duplicates"
485+ "issue with numpy>=1.25 with AVX instructions"
486+ ),
487+ strict = False ,
488+ )
489+ )
459490 gp = nulls_df .groupby (["A" , "B" ], dropna = group_dropna )
460491 result = gp .value_counts (normalize = True , sort = True , dropna = count_dropna )
461492 columns = DataFrame ()
@@ -546,10 +577,20 @@ def test_data_frame_value_counts_dropna(
546577 ],
547578)
548579def test_categorical_single_grouper_with_only_observed_categories (
549- education_df , as_index , observed , normalize , name , expected_data
580+ education_df , as_index , observed , normalize , name , expected_data , request
550581):
551582 # Test single categorical grouper with only observed grouping categories
552583 # when non-groupers are also categorical
584+ if Version (np .__version__ ) >= Version ("1.25" ):
585+ request .node .add_marker (
586+ pytest .mark .xfail (
587+ reason = (
588+ "pandas default unstable sorting of duplicates"
589+ "issue with numpy>=1.25 with AVX instructions"
590+ ),
591+ strict = False ,
592+ )
593+ )
553594
554595 gp = education_df .astype ("category" ).groupby (
555596 "country" , as_index = as_index , observed = observed
@@ -645,10 +686,21 @@ def assert_categorical_single_grouper(
645686 ],
646687)
647688def test_categorical_single_grouper_observed_true (
648- education_df , as_index , normalize , name , expected_data
689+ education_df , as_index , normalize , name , expected_data , request
649690):
650691 # GH#46357
651692
693+ if Version (np .__version__ ) >= Version ("1.25" ):
694+ request .node .add_marker (
695+ pytest .mark .xfail (
696+ reason = (
697+ "pandas default unstable sorting of duplicates"
698+ "issue with numpy>=1.25 with AVX instructions"
699+ ),
700+ strict = False ,
701+ )
702+ )
703+
652704 expected_index = [
653705 ("FR" , "male" , "low" ),
654706 ("FR" , "female" , "high" ),
@@ -715,10 +767,21 @@ def test_categorical_single_grouper_observed_true(
715767 ],
716768)
717769def test_categorical_single_grouper_observed_false (
718- education_df , as_index , normalize , name , expected_data
770+ education_df , as_index , normalize , name , expected_data , request
719771):
720772 # GH#46357
721773
774+ if Version (np .__version__ ) >= Version ("1.25" ):
775+ request .node .add_marker (
776+ pytest .mark .xfail (
777+ reason = (
778+ "pandas default unstable sorting of duplicates"
779+ "issue with numpy>=1.25 with AVX instructions"
780+ ),
781+ strict = False ,
782+ )
783+ )
784+
722785 expected_index = [
723786 ("FR" , "male" , "low" ),
724787 ("FR" , "female" , "high" ),
@@ -856,10 +919,22 @@ def test_categorical_multiple_groupers(
856919 ],
857920)
858921def test_categorical_non_groupers (
859- education_df , as_index , observed , normalize , name , expected_data
922+ education_df , as_index , observed , normalize , name , expected_data , request
860923):
861924 # GH#46357 Test non-observed categories are included in the result,
862925 # regardless of `observed`
926+
927+ if Version (np .__version__ ) >= Version ("1.25" ):
928+ request .node .add_marker (
929+ pytest .mark .xfail (
930+ reason = (
931+ "pandas default unstable sorting of duplicates"
932+ "issue with numpy>=1.25 with AVX instructions"
933+ ),
934+ strict = False ,
935+ )
936+ )
937+
863938 education_df = education_df .copy ()
864939 education_df ["gender" ] = education_df ["gender" ].astype ("category" )
865940 education_df ["education" ] = education_df ["education" ].astype ("category" )
0 commit comments