@@ -637,6 +637,13 @@ def test_pie_series(self):
637
637
ax = _check_plot_works (series .plot , kind = 'pie' )
638
638
self ._check_text_labels (ax .texts , series .index )
639
639
640
+ def test_pie_nan (self ):
641
+ s = Series ([1 , np .nan , 1 , 1 ])
642
+ ax = s .plot (kind = 'pie' , legend = True )
643
+ expected = ['0' , '' , '2' , '3' ]
644
+ result = [x .get_text () for x in ax .texts ]
645
+ self .assertEqual (result , expected )
646
+
640
647
@slow
641
648
def test_hist_df_kwargs (self ):
642
649
df = DataFrame (np .random .randn (10 , 2 ))
@@ -2782,6 +2789,22 @@ def test_pie_df(self):
2782
2789
self ._check_text_labels (ax .texts , labels )
2783
2790
self ._check_colors (ax .patches , facecolors = color_args )
2784
2791
2792
+ def test_pie_df_nan (self ):
2793
+ df = DataFrame (np .random .rand (4 , 4 ))
2794
+ for i in range (4 ):
2795
+ df .iloc [i , i ] = np .nan
2796
+ fig , axes = self .plt .subplots (ncols = 4 )
2797
+ df .plot (kind = 'pie' , subplots = True , ax = axes , legend = True )
2798
+
2799
+ base_expected = ['0' , '1' , '2' , '3' ]
2800
+ for i , ax in enumerate (axes ):
2801
+ expected = list (base_expected ) # copy
2802
+ expected [i ] = ''
2803
+ result = [x .get_text () for x in ax .texts ]
2804
+ self .assertEqual (result , expected )
2805
+ # legend labels
2806
+ self .assertEqual ([x .get_text () for x in ax .get_legend ().get_texts ()],
2807
+ base_expected )
2785
2808
def test_errorbar_plot (self ):
2786
2809
d = {'x' : np .arange (12 ), 'y' : np .arange (12 , 0 , - 1 )}
2787
2810
df = DataFrame (d )
0 commit comments