示例#1
0
 def test_row(self):
     dxp.scatter(x='neighborhood',
                 y='price',
                 data=airbnb,
                 aggfunc='median',
                 split='superhost',
                 row='property_type')
示例#2
0
 def test_stacked(self):
     dxp.scatter(x='neighborhood',
                 y='price',
                 data=airbnb,
                 aggfunc='median',
                 split='superhost',
                 split_order=['Yes', 'No'])
示例#3
0
 def test_row_order(self):
     dxp.scatter(x='neighborhood',
                 y='price',
                 data=airbnb,
                 aggfunc='median',
                 split='superhost',
                 row='property_type',
                 row_order=['House', 'Condominium'])
示例#4
0
 def test_col_wrap(self):
     dxp.scatter(x='neighborhood',
                 y='price',
                 data=airbnb,
                 aggfunc='median',
                 split='superhost',
                 col='property_type',
                 wrap=2)
示例#5
0
 def test_function(self):
     dxp.scatter(x='neighborhood',
                 y='price',
                 data=airbnb,
                 aggfunc=np.median)
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc=np.mean)
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc=np.min)
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc=np.max)
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc=np.size)
示例#6
0
 def test_row_col(self):
     dxp.scatter(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])
示例#7
0
    def test_x_order(self):
        dxp.scatter(x='neighborhood',
                    y='price',
                    data=airbnb,
                    aggfunc='median',
                    x_order=['Dupont Circle', 'Edgewood', 'Union Station'])

        with pytest.raises(ValueError):
            dxp.scatter(
                x='neighborhood',
                y='price',
                data=airbnb,
                aggfunc='median',
                x_order=['Dupont Circle', 'Edgewood', 'DOES NOT EXIST'])
示例#8
0
 def test_lex_asc(self):
     fig = dxp.scatter(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
示例#9
0
 def test_lex_desc(self):
     fig = dxp.scatter(x='neighborhood',
                       y='price',
                       data=airbnb,
                       aggfunc='median',
                       sort_values='lex_desc')
     ticklabels = [t.get_text() for t in fig.axes[0].get_xticklabels()]
     correct = sorted(ticklabels, reverse=True)
     assert ticklabels == correct
示例#10
0
    def test_asc_values(self):
        fig = dxp.scatter(x='neighborhood',
                          y='price',
                          data=airbnb,
                          aggfunc='median',
                          sort='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
示例#11
0
    def test_desc_values(self):
        fig = dxp.scatter(x='neighborhood',
                          y='price',
                          data=airbnb,
                          aggfunc='median',
                          sort='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
示例#12
0
 def test_horiz(self):
     dxp.scatter(x='price',
                 y='neighborhood',
                 data=airbnb,
                 aggfunc='median',
                 orientation='h')
示例#13
0
 def test_string_name(self):
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc='median')
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc='mean')
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc='min')
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc='max')
     dxp.scatter(x='neighborhood', y='price', data=airbnb, aggfunc='size')
示例#14
0
 def test_split(self):
     dxp.scatter(x='neighborhood',
                 y='price',
                 data=airbnb,
                 aggfunc='median',
                 split='superhost')