Beispiel #1
0
 def test_row(self):
     dxp.line(x='neighborhood',
              y='price',
              data=airbnb,
              aggfunc='median',
              split='superhost',
              row='property_type')
Beispiel #2
0
 def test_stacked(self):
     dxp.line(x='neighborhood',
              y='price',
              data=airbnb,
              aggfunc='median',
              split='superhost',
              split_order=['Yes', 'No'])
Beispiel #3
0
 def test_row_order(self):
     dxp.line(x='neighborhood',
              y='price',
              data=airbnb,
              aggfunc='median',
              split='superhost',
              row='property_type',
              row_order=['House', 'Condominium'])
Beispiel #4
0
 def test_col_wrap(self):
     dxp.line(x='neighborhood',
              y='price',
              data=airbnb,
              aggfunc='median',
              split='superhost',
              col='property_type',
              wrap=2)
Beispiel #5
0
 def test_row_col(self):
     dxp.line(x='neighborhood',
              y='price',
              data=airbnb,
              aggfunc='median',
              split='superhost',
              col='property_type',
              col_order=['House', 'Condominium', 'Apartment'],
              row='bedrooms',
              row_order=[0, 1, 2, 3])
Beispiel #6
0
    def test_x_order(self):
        dxp.line(x='neighborhood',
                 y='price',
                 data=airbnb,
                 aggfunc='median',
                 x_order=['Dupont Circle', 'Edgewood', 'Union Station'])

        with pytest.raises(ValueError):
            dxp.line(x='neighborhood',
                     y='price',
                     data=airbnb,
                     aggfunc='median',
                     x_order=['Dupont Circle', 'Edgewood', 'DOES NOT EXIST'])
Beispiel #7
0
 def test_lex_asc(self):
     fig = dxp.line(x='neighborhood',
                    y='price',
                    data=airbnb,
                    aggfunc='median')
     ticklabels = [t.get_text() for t in fig.axes[0].get_xticklabels()]
     correct = sorted(ticklabels)
     assert ticklabels == correct
Beispiel #8
0
    def test_asc_values(self):
        fig = dxp.line(x='neighborhood',
                       y='price',
                       data=airbnb,
                       aggfunc='median',
                       sort_values='asc')
        ticklabels = [t.get_text() for t in fig.axes[0].get_xticklabels()]
        ticklabels = [label.replace('\n', ' ') for label in ticklabels]
        values = [p.get_height() for p in fig.axes[0].patches]

        s = airbnb.groupby('neighborhood')['price'].median().sort_values()
        correct_labels = s.index.tolist()
        correct_values = s.values.tolist()
        assert ticklabels == correct_labels
Beispiel #9
0
    def test_desc_values(self):
        fig = dxp.line(x='neighborhood',
                       y='price',
                       data=airbnb,
                       aggfunc='median',
                       sort_values='desc')
        ticklabels = [t.get_text() for t in fig.axes[0].get_xticklabels()]
        ticklabels = [label.replace('\n', ' ') for label in ticklabels]
        values = [p.get_height() for p in fig.axes[0].patches]

        df = airbnb.groupby('neighborhood').agg({'price': 'median'}).reset_index() \
                   .sort_values(['price', 'neighborhood'], ascending=[False, True])
        s = df.set_index('neighborhood').squeeze()
        correct_labels = s.index.tolist()
        correct_values = s.values.tolist()
        assert ticklabels == correct_labels
Beispiel #10
0
 def test_horiz(self):
     dxp.line(x='price',
              y='neighborhood',
              data=airbnb,
              aggfunc='median',
              orientation='h')
Beispiel #11
0
 def test_string_name(self):
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc='median')
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc='mean')
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc='min')
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc='max')
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc='size')
Beispiel #12
0
 def test_function(self):
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc=np.median)
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc=np.mean)
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc=np.min)
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc=np.max)
     dxp.line(x='neighborhood', y='price', data=airbnb, aggfunc=np.size)
Beispiel #13
0
 def test_split(self):
     dxp.line(x='neighborhood',
              y='price',
              data=airbnb,
              aggfunc='median',
              split='superhost')