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 ():
@@ -244,8 +245,18 @@ def test_bad_subset(education_df):
244
245
gp .value_counts (subset = ["country" ])
245
246
246
247
247
- def test_basic (education_df ):
248
+ def test_basic (education_df , request ):
248
249
# 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
+ )
249
260
result = education_df .groupby ("country" )[["gender" , "education" ]].value_counts (
250
261
normalize = True
251
262
)
@@ -283,7 +294,7 @@ def _frame_value_counts(df, keys, normalize, sort, ascending):
283
294
@pytest .mark .parametrize ("as_index" , [True , False ])
284
295
@pytest .mark .parametrize ("frame" , [True , False ])
285
296
def 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
287
298
):
288
299
# test all parameters:
289
300
# - Use column, array or function as by= parameter
@@ -293,6 +304,16 @@ def test_against_frame_and_seriesgroupby(
293
304
# - 3-way compare against:
294
305
# - apply with :meth:`~DataFrame.value_counts`
295
306
# - `~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
+ )
296
317
by = {
297
318
"column" : "country" ,
298
319
"array" : education_df ["country" ].values ,
@@ -454,8 +475,18 @@ def nulls_df():
454
475
],
455
476
)
456
477
def 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
458
479
):
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
+ )
459
490
gp = nulls_df .groupby (["A" , "B" ], dropna = group_dropna )
460
491
result = gp .value_counts (normalize = True , sort = True , dropna = count_dropna )
461
492
columns = DataFrame ()
@@ -546,10 +577,20 @@ def test_data_frame_value_counts_dropna(
546
577
],
547
578
)
548
579
def 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
550
581
):
551
582
# Test single categorical grouper with only observed grouping categories
552
583
# 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
+ )
553
594
554
595
gp = education_df .astype ("category" ).groupby (
555
596
"country" , as_index = as_index , observed = observed
@@ -645,10 +686,21 @@ def assert_categorical_single_grouper(
645
686
],
646
687
)
647
688
def 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
649
690
):
650
691
# GH#46357
651
692
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
+
652
704
expected_index = [
653
705
("FR" , "male" , "low" ),
654
706
("FR" , "female" , "high" ),
@@ -715,10 +767,21 @@ def test_categorical_single_grouper_observed_true(
715
767
],
716
768
)
717
769
def 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
719
771
):
720
772
# GH#46357
721
773
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
+
722
785
expected_index = [
723
786
("FR" , "male" , "low" ),
724
787
("FR" , "female" , "high" ),
@@ -856,10 +919,22 @@ def test_categorical_multiple_groupers(
856
919
],
857
920
)
858
921
def 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
860
923
):
861
924
# GH#46357 Test non-observed categories are included in the result,
862
925
# 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
+
863
938
education_df = education_df .copy ()
864
939
education_df ["gender" ] = education_df ["gender" ].astype ("category" )
865
940
education_df ["education" ] = education_df ["education" ].astype ("category" )
0 commit comments