@@ -637,6 +637,13 @@ def test_pie_series(self):
637637 ax = _check_plot_works (series .plot , kind = 'pie' )
638638 self ._check_text_labels (ax .texts , series .index )
639639
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+
640647 @slow
641648 def test_hist_df_kwargs (self ):
642649 df = DataFrame (np .random .randn (10 , 2 ))
@@ -2782,6 +2789,22 @@ def test_pie_df(self):
27822789 self ._check_text_labels (ax .texts , labels )
27832790 self ._check_colors (ax .patches , facecolors = color_args )
27842791
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 )
27852808 def test_errorbar_plot (self ):
27862809 d = {'x' : np .arange (12 ), 'y' : np .arange (12 , 0 , - 1 )}
27872810 df = DataFrame (d )
0 commit comments