33
33
import pandas as pd
34
34
from numpy .testing import assert_equal
35
35
36
+ def _skip_if_mpl_not_installed ():
37
+ try :
38
+ import matplotlib .pyplot as plt
39
+ except ImportError :
40
+ raise nose .SkipTest ("matplotlib not installed" )
36
41
37
42
def commonSetUp (self ):
38
43
self .dateRange = bdate_range ('1/1/2005' , periods = 250 )
@@ -3976,11 +3981,8 @@ def test_groupby_blacklist(self):
3976
3981
getattr (gb , bl )
3977
3982
3978
3983
def test_series_groupby_plotting_nominally_works (self ):
3979
- try :
3980
- import matplotlib as mpl
3981
- mpl .use ('Agg' )
3982
- except ImportError :
3983
- raise nose .SkipTest ("matplotlib not installed" )
3984
+ _skip_if_mpl_not_installed ()
3985
+
3984
3986
n = 10
3985
3987
weight = Series (np .random .normal (166 , 20 , size = n ))
3986
3988
height = Series (np .random .normal (60 , 10 , size = n ))
@@ -3991,14 +3993,26 @@ def test_series_groupby_plotting_nominally_works(self):
3991
3993
height .groupby (gender ).hist ()
3992
3994
tm .close ()
3993
3995
3996
+ def test_plotting_with_float_index_works (self ):
3997
+ _skip_if_mpl_not_installed ()
3998
+
3999
+ # GH 7025
4000
+ df = DataFrame ({'def' : [1 ,1 ,1 ,2 ,2 ,2 ,3 ,3 ,3 ],
4001
+ 'val' : np .random .randn (9 )},
4002
+ index = [1.0 ,2.0 ,3.0 ,1.0 ,2.0 ,3.0 ,1.0 ,2.0 ,3.0 ])
4003
+
4004
+ df .groupby ('def' )['val' ].plot ()
4005
+ tm .close ()
4006
+ df .groupby ('def' )['val' ].apply (lambda x : x .plot ())
4007
+ tm .close ()
4008
+
3994
4009
@slow
3995
4010
def test_frame_groupby_plot_boxplot (self ):
3996
- try :
3997
- import matplotlib .pyplot as plt
3998
- import matplotlib as mpl
3999
- mpl .use ('Agg' )
4000
- except ImportError :
4001
- raise nose .SkipTest ("matplotlib not installed" )
4011
+ _skip_if_mpl_not_installed ()
4012
+
4013
+ import matplotlib .pyplot as plt
4014
+ import matplotlib as mpl
4015
+ mpl .use ('Agg' )
4002
4016
tm .close ()
4003
4017
4004
4018
n = 10
@@ -4029,12 +4043,10 @@ def test_frame_groupby_plot_boxplot(self):
4029
4043
4030
4044
@slow
4031
4045
def test_frame_groupby_hist (self ):
4032
- try :
4033
- import matplotlib .pyplot as plt
4034
- import matplotlib as mpl
4035
- mpl .use ('Agg' )
4036
- except ImportError :
4037
- raise nose .SkipTest ("matplotlib not installed" )
4046
+ _skip_if_mpl_not_installed ()
4047
+ import matplotlib .pyplot as plt
4048
+ import matplotlib as mpl
4049
+ mpl .use ('Agg' )
4038
4050
tm .close ()
4039
4051
4040
4052
n = 10
0 commit comments