1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
U
­ý°dâã@sldZddlZddlZddlmmZddlm    Z    m
Z
m Z ddl m ZddlmZejGdd„deƒƒZdS)z Test cases for GroupBy.plot éN)Ú    DataFrameÚIndexÚSeries)Ú TestPlotBasec@sxeZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zej     
d d d g¡dd„ƒZ ej     
dddg¡dd„ƒZ dd„Z dd„ZdS)ÚTestDataFrameGroupByPlotscCs”d}ttjjdd|dƒ}ttjjdd|dƒ}tj d¡jddg|d}| |¡ ¡t     ¡| |¡ 
¡t     ¡| |¡jd    d
t     ¡dS) Né
é¦é)Úsizeé<é*ZmaleZfemalegà?)Úalpha) rÚnpÚrandomÚnormalZ RandomStateÚchoiceÚgroupbyÚplotÚtmÚcloseÚhist)ÚselfÚnZweightÚheightZgender©rúYd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/plotting/test_groupby.pyÚ,test_series_groupby_plotting_nominally_worksszFTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_worksc Cs|tdddddddddg    tj d¡dœdddddddddg    d    }| d
¡d  ¡t ¡| d
¡d  d d „¡t ¡dS)Néééé    )ÚdefÚvalgð?g@g@)Úindexr!r"cSs| ¡S)N)r)ÚxrrrÚ<lambda>+ózPTestDataFrameGroupByPlots.test_plotting_with_float_index_works.<locals>.<lambda>)    rrrÚrandnrrrrÚapply©rÚdfrrrÚ$test_plotting_with_float_index_works"s"þz>TestDataFrameGroupByPlots.test_plotting_with_float_index_workscCspt ddd¡}tddgddgddgd    œƒ}|d
j|d |d tdgdgdgd    œƒ}|d
j|d |d dS) NéPéfrZAAAZBBBréUéY)ÚNameÚByColÚMarkr2r1)ZbyÚbins)rZarangerr)rr3r*rrrÚtest_hist_single_row.s
z.TestDataFrameGroupByPlots.test_hist_single_rowcCsdtdddddgdddddgtdƒdœƒ}| d¡j d    d
¡t ¡| d¡d    j ¡t ¡dS) NrrrééÚababa©r$ÚyÚzr:r$r9)rÚlistrrÚscatterrrÚliner)rrrÚtest_plot_submethod_works6s
(z3TestDataFrameGroupByPlots.test_plot_submethod_workscCs„tdddddgdddddgtdƒdœƒ}| d¡jd    d
d d }t|d jƒdksTt‚| d¡jjd
d d}t|d jƒdks€t‚dS)Nrrrr5r6r7r8r:r<r$r9)Úkindr$r9Úa)r$r9)rr;rrÚlenÚ collectionsÚAssertionErrorr<)rr*ÚresrrrÚtest_plot_kwargs=s
(z*TestDataFrameGroupByPlots.test_plot_kwargszcolumn, expected_axes_num)Nr)Úbrc Cs¦d|f}|pdgdgg}tddgddgdd}ttj d    d
¡|ddgd }| d¡}|jd |d D]8}|j|||dt|d|ƒD]\}    }
|     |    |
¡qŠqhdS)Nrr@rFéÚ1Ú2Úc©Únameér©r#ÚcolumnsT)ÚlegendÚcolumn©Zaxes_numZlayoutr)
rrrrr'rrÚ_check_axes_shapeÚzipÚ_check_legend_labels) rrQZexpected_axes_numZexpected_layoutZexpected_labelsr#r*ÚgZaxesÚaxZexpected_labelrrrÚ#test_groupby_hist_frame_with_legendHs
ÿz=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrQNrFc    Csptddgddgdd}ttj dd¡|dd    gd
}| d¡}tjtd d |j    d |ddW5QRXdS)NrGrHrIrJrKrMrr@rFrNú Cannot use both legend and label©ÚmatchTÚd)rPrQÚlabel©
rrrrr'rÚpytestZraisesÚ
ValueErrorr)rrQr#r*rVrrrÚ*test_groupby_hist_frame_with_legend_raisesYs
 
zDTestDataFrameGroupByPlots.test_groupby_hist_frame_with_legend_raisescCs|tddgddgdd}ttj dd¡|dd    gd
}| d¡}|djd d D]$}|j|d dd| |ddg¡qRdS)NrGrHrIrJrKrMrr@rFrNT)rPr)rrrR)    rrrrr'rrrSrU)rr#r*rVrWrrrÚ$test_groupby_hist_series_with_legendcs 
z>TestDataFrameGroupByPlots.test_groupby_hist_series_with_legendc    Csntddgddgdd}ttj dd¡|dd    gd
}| d¡}tjtd d |j    d ddW5QRXdS)NrGrHrIrJrKrMrr@rFrNrYrZTr\)rPr]r^)rr#r*rVrrrÚ+test_groupby_hist_series_with_legend_raisesms
 
zETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raises)Ú__name__Ú
__module__Ú __qualname__rr+r4r>rEr_ÚmarkZ parametrizerXrarbrcrrrrrs  
 
    
r)Ú__doc__Únumpyrr_Zpandas.util._test_decoratorsÚutilZ_test_decoratorsÚtdZpandasrrrZpandas._testingZ_testingrZpandas.tests.plotting.commonrZskip_if_no_mplrrrrrÚ<module>s