21
21
to_datetime ,
22
22
)
23
23
import pandas ._testing as tm
24
+ from pandas .util .version import Version
24
25
25
26
26
27
def tests_value_counts_index_names_category_column ():
@@ -246,8 +247,18 @@ def test_bad_subset(education_df):
246
247
gp .value_counts (subset = ["country" ])
247
248
248
249
249
- def test_basic (education_df ):
250
+ def test_basic (education_df , request ):
250
251
# gh43564
252
+ if Version (np .__version__ ) >= Version ("1.25" ):
253
+ request .node .add_marker (
254
+ pytest .mark .xfail (
255
+ reason = (
256
+ "pandas default unstable sorting of duplicates"
257
+ "issue with numpy>=1.25 with AVX instructions"
258
+ ),
259
+ strict = False ,
260
+ )
261
+ )
251
262
result = education_df .groupby ("country" )[["gender" , "education" ]].value_counts (
252
263
normalize = True
253
264
)
@@ -285,7 +296,7 @@ def _frame_value_counts(df, keys, normalize, sort, ascending):
285
296
@pytest .mark .parametrize ("as_index" , [True , False ])
286
297
@pytest .mark .parametrize ("frame" , [True , False ])
287
298
def test_against_frame_and_seriesgroupby (
288
- education_df , groupby , normalize , name , sort , ascending , as_index , frame
299
+ education_df , groupby , normalize , name , sort , ascending , as_index , frame , request
289
300
):
290
301
# test all parameters:
291
302
# - Use column, array or function as by= parameter
@@ -295,6 +306,16 @@ def test_against_frame_and_seriesgroupby(
295
306
# - 3-way compare against:
296
307
# - apply with :meth:`~DataFrame.value_counts`
297
308
# - `~SeriesGroupBy.value_counts`
309
+ if Version (np .__version__ ) >= Version ("1.25" ) and frame and sort and normalize :
310
+ request .node .add_marker (
311
+ pytest .mark .xfail (
312
+ reason = (
313
+ "pandas default unstable sorting of duplicates"
314
+ "issue with numpy>=1.25 with AVX instructions"
315
+ ),
316
+ strict = False ,
317
+ )
318
+ )
298
319
by = {
299
320
"column" : "country" ,
300
321
"array" : education_df ["country" ].values ,
@@ -456,8 +477,18 @@ def nulls_df():
456
477
],
457
478
)
458
479
def test_dropna_combinations (
459
- nulls_df , group_dropna , count_dropna , expected_rows , expected_values
480
+ nulls_df , group_dropna , count_dropna , expected_rows , expected_values , request
460
481
):
482
+ if Version (np .__version__ ) >= Version ("1.25" ) and not group_dropna :
483
+ request .node .add_marker (
484
+ pytest .mark .xfail (
485
+ reason = (
486
+ "pandas default unstable sorting of duplicates"
487
+ "issue with numpy>=1.25 with AVX instructions"
488
+ ),
489
+ strict = False ,
490
+ )
491
+ )
461
492
gp = nulls_df .groupby (["A" , "B" ], dropna = group_dropna )
462
493
result = gp .value_counts (normalize = True , sort = True , dropna = count_dropna )
463
494
columns = DataFrame ()
@@ -548,10 +579,20 @@ def test_data_frame_value_counts_dropna(
548
579
],
549
580
)
550
581
def test_categorical_single_grouper_with_only_observed_categories (
551
- education_df , as_index , observed , normalize , name , expected_data
582
+ education_df , as_index , observed , normalize , name , expected_data , request
552
583
):
553
584
# Test single categorical grouper with only observed grouping categories
554
585
# when non-groupers are also categorical
586
+ if Version (np .__version__ ) >= Version ("1.25" ):
587
+ request .node .add_marker (
588
+ pytest .mark .xfail (
589
+ reason = (
590
+ "pandas default unstable sorting of duplicates"
591
+ "issue with numpy>=1.25 with AVX instructions"
592
+ ),
593
+ strict = False ,
594
+ )
595
+ )
555
596
556
597
gp = education_df .astype ("category" ).groupby (
557
598
"country" , as_index = as_index , observed = observed
@@ -647,10 +688,21 @@ def assert_categorical_single_grouper(
647
688
],
648
689
)
649
690
def test_categorical_single_grouper_observed_true (
650
- education_df , as_index , normalize , name , expected_data
691
+ education_df , as_index , normalize , name , expected_data , request
651
692
):
652
693
# GH#46357
653
694
695
+ if Version (np .__version__ ) >= Version ("1.25" ):
696
+ request .node .add_marker (
697
+ pytest .mark .xfail (
698
+ reason = (
699
+ "pandas default unstable sorting of duplicates"
700
+ "issue with numpy>=1.25 with AVX instructions"
701
+ ),
702
+ strict = False ,
703
+ )
704
+ )
705
+
654
706
expected_index = [
655
707
("FR" , "male" , "low" ),
656
708
("FR" , "female" , "high" ),
@@ -717,10 +769,21 @@ def test_categorical_single_grouper_observed_true(
717
769
],
718
770
)
719
771
def test_categorical_single_grouper_observed_false (
720
- education_df , as_index , normalize , name , expected_data
772
+ education_df , as_index , normalize , name , expected_data , request
721
773
):
722
774
# GH#46357
723
775
776
+ if Version (np .__version__ ) >= Version ("1.25" ):
777
+ request .node .add_marker (
778
+ pytest .mark .xfail (
779
+ reason = (
780
+ "pandas default unstable sorting of duplicates"
781
+ "issue with numpy>=1.25 with AVX instructions"
782
+ ),
783
+ strict = False ,
784
+ )
785
+ )
786
+
724
787
expected_index = [
725
788
("FR" , "male" , "low" ),
726
789
("FR" , "female" , "high" ),
@@ -858,10 +921,22 @@ def test_categorical_multiple_groupers(
858
921
],
859
922
)
860
923
def test_categorical_non_groupers (
861
- education_df , as_index , observed , normalize , name , expected_data
924
+ education_df , as_index , observed , normalize , name , expected_data , request
862
925
):
863
926
# GH#46357 Test non-observed categories are included in the result,
864
927
# regardless of `observed`
928
+
929
+ if Version (np .__version__ ) >= Version ("1.25" ):
930
+ request .node .add_marker (
931
+ pytest .mark .xfail (
932
+ reason = (
933
+ "pandas default unstable sorting of duplicates"
934
+ "issue with numpy>=1.25 with AVX instructions"
935
+ ),
936
+ strict = False ,
937
+ )
938
+ )
939
+
865
940
education_df = education_df .copy ()
866
941
education_df ["gender" ] = education_df ["gender" ].astype ("category" )
867
942
education_df ["education" ] = education_df ["education" ].astype ("category" )
0 commit comments