Example #1
0
                if year == 2010:
                    plt.ylabel('Percent of Total Expenditures')
                handles.extend(handle_for_school)
            except KeyError:  ##School not in dataset for year
                ax.axis('off')
                ax.text(0.5,
                        0.5,
                        'Data not available\nfor {}'.format(str(year)),
                        fontsize=16,
                        horizontalalignment='center',
                        verticalalignment='center',
                        transform=ax.transAxes)

        legend_corner = plt.subplot(3, 4, 12)
        legend_corner.axis('off')
        unique_handles = []
        for patch in handles:
            if patch.get_label() in handle_labels:
                pass
            else:
                handle_labels.append(patch.get_label())
                unique_handles.append(patch)
        plt.legend(handles=unique_handles,
                   fontsize='medium',
                   loc='center',
                   title='Legend')


from check_data_and_ipython_call import try_call_function
try_call_function(school_dashboard)
        plot_by_feature = ['total_enrollment', 'ell_percent', 'sped_percent', 'asian_per', 'black_per', 'hispanic_per', 'white_per', 'male_per', 'female_per', 'poverty_level', 'elementary_school', 'middle_school', 'high_school']
        keys = [re.sub('_', ' ', x) for x in plot_by_feature]
        keys = [re.sub('sped', 'Special Education',  x) for x in keys]
        keys = [re.sub('ell', 'English Language Learner', x) for x in keys]
        keys = [re.sub('per$', 'percent', x) for x in keys]
        keys = [x.title() for x in keys]
        map_features_to_keys = dict(zip(plot_by_feature, keys))
        return map_features_to_keys
    
    def map_feature_to_key(self, feature):
        '''
        This function maps an input feature name to the corresponding human-readable, informative description produced
        by make_labels_from_features.
        '''
        map_feature_to_keys = self.make_labels_from_features()
        return map_feature_to_keys[feature]
    
    def make_keys_for_interactive_widget(self):
        '''
        This function inverts the self.features_for_widgets dictionary (mapping values back to keys), so the dictionary
        is in the format expected by the interactive widget.
        ''' 
        features=self.make_labels_from_features()
        features = {v: k for k, v in features.items()}
        return features
    


from check_data_and_ipython_call import try_call_function
try_call_function(pca_explorer)
                        horizontalalignment='center', verticalalignment='center', transform=ax.transAxes)
                
        for year in range(2010, 2013):
            ax = plt.subplot(3,4, year-2001)
            ax.set_title(str(year))
            try:
                handle_for_school, school, compare = self.make_sub_plot(year, DBN)
                if year == 2010:
                    plt.ylabel('Percent of Total Expenditures')
                handles.extend(handle_for_school)
            except KeyError: ##School not in dataset for year
                ax.axis('off')
                ax.text(0.5, 0.5,'Data not available\nfor {}'.format(str(year)), fontsize=16,
                        horizontalalignment='center', verticalalignment='center', transform=ax.transAxes)
    
        legend_corner = plt.subplot(3,4,12)
        legend_corner.axis('off')
        unique_handles = []
        for patch in handles:
            if patch.get_label() in handle_labels:
                pass
            else:
                handle_labels.append(patch.get_label())
                unique_handles.append(patch)
        plt.legend(handles=unique_handles, fontsize='medium', loc='center', title='Legend')



from check_data_and_ipython_call import try_call_function
try_call_function(school_dashboard)
Example #4
0
 'School Safety': 'School_Safety',
 'Secretaries, School Aides, and Other Support Staff': 'Secretaries_School_Aides__Other_Support_Staff',
 'Summer And Evening School': 'Summer_and_Evening_School',
 'Supervisors': 'Supervisors',
 'Leadership Supplies, Materials, Equipment, and Telephones': 'Supplies_Materials_Equipment_Telephones',
 'Teachers': 'Teachers',
 'Text Books': 'Text_Books',
 'Total': 'Total',
 'Transportation': 'Transportation'}
    
    def build_groupby_dicts(self):
        return {'Elementary School': 'elementary_school',
 'High School': 'high_school',
 'Middle School': 'middle_school',
 'Percent Students Asian ': 'asian_per',
 'Percent Students Black ': 'black_per',
 'Percent Students English Language Learners': 'ell_percent',
 'Percent Students Female ': 'female_per',
 'Percent Students Hispanic ': 'hispanic_per',
 'Percent Students Male ': 'male_per',
 'Percent Students Special Education': 'sped_percent',
 'Percent Students White ': 'white_per',
 'Poverty Level': 'poverty_level',
 'Title 1': 'Title_1',
 'Total Enrollment': 'total_enrollment'}
        

from check_data_and_ipython_call import try_call_function

try_call_function(boxplot_comparisons)
        
Example #5
0
            'high_school'
        ]
        keys = [re.sub('_', ' ', x) for x in plot_by_feature]
        keys = [re.sub('sped', 'Special Education', x) for x in keys]
        keys = [re.sub('ell', 'English Language Learner', x) for x in keys]
        keys = [re.sub('per$', 'percent', x) for x in keys]
        keys = [x.title() for x in keys]
        map_features_to_keys = dict(zip(plot_by_feature, keys))
        return map_features_to_keys

    def map_feature_to_key(self, feature):
        '''
        This function maps an input feature name to the corresponding human-readable, informative description produced
        by make_labels_from_features.
        '''
        map_feature_to_keys = self.make_labels_from_features()
        return map_feature_to_keys[feature]

    def make_keys_for_interactive_widget(self):
        '''
        This function inverts the self.features_for_widgets dictionary (mapping values back to keys), so the dictionary
        is in the format expected by the interactive widget.
        '''
        features = self.make_labels_from_features()
        features = {v: k for k, v in features.items()}
        return features


from check_data_and_ipython_call import try_call_function
try_call_function(pca_explorer)
            'Classroom_Instruction_All_Funds_percent_of_total',
            'Field Support- Percent of Total':
            'Field_Support_All_Funds_percent_of_total',
            'Instructional Support And Administration- Percent of Total':
            'Instructional_Support_and_Administration_All_Funds_percent_of_total',
            'Instructional Support Services- Percent of Total':
            'Instructional_Support_Srcs_All_Funds_percent_of_total',
            'Leadership, Supervision, and Support- Percent of Total':
            'LeadershipSupervisionSupport_All_Funds_percent_of_total',
            'Other Field Support Costs- Percent of Total':
            'Other_Field_Support_Costs_All_Funds_percent_of_total',
            'Referral And Evaluation Services- Percent of Total':
            'Referral_and_Evaluation_Services_All_Funds_percent_of_total',
            'Total': 'Total'
        }
        return features

    def features_for_labels(self, feature):
        '''
        This function inverts the self.features_for_widgets dictionary (mapping values back to keys), so the dictionary
        is in the format expected by the interactive widget.
        '''
        features = self.features_for_interaction()
        features = {v: k for k, v in features.items()}
        return features[feature]


from check_data_and_ipython_call import try_call_function

try_call_function(NYC_school_interactive_map)
        '''
        This method can be called to get the dictionary mapping .
        '''
        features = {'Ancillary Support Services- Percent of Total': 'Ancillary_Support_Services_All_Funds_percent_of_total',
 'Building Services- Percent of Total': 'Building_Services_All_Funds_percent_of_total',
 'Central Administration- Percent of Total': 'Central_Administration_All_Funds_percent_of_total',
 'Central Instructional Support- Percent of Total': 'Central_Instructional_Support_All_Funds_percent_of_total',
 'Classroom Instruction- Percent of Total': 'Classroom_Instruction_All_Funds_percent_of_total',
 'Field Support- Percent of Total': 'Field_Support_All_Funds_percent_of_total',
 'Instructional Support And Administration- Percent of Total': 'Instructional_Support_and_Administration_All_Funds_percent_of_total',
 'Instructional Support Services- Percent of Total': 'Instructional_Support_Srcs_All_Funds_percent_of_total',
 'Leadership, Supervision, and Support- Percent of Total': 'LeadershipSupervisionSupport_All_Funds_percent_of_total',
 'Other Field Support Costs- Percent of Total': 'Other_Field_Support_Costs_All_Funds_percent_of_total',
 'Referral And Evaluation Services- Percent of Total': 'Referral_and_Evaluation_Services_All_Funds_percent_of_total',
 'Total': 'Total'}
        return features
    
    def features_for_labels(self, feature):
        '''
        This function inverts the self.features_for_widgets dictionary (mapping values back to keys), so the dictionary
        is in the format expected by the interactive widget.
        ''' 
        features=self.features_for_interaction()
        features = {v: k for k, v in features.items()}
        return features[feature]


from check_data_and_ipython_call import try_call_function

try_call_function(NYC_school_interactive_map)