Commit 1c41a3c9 authored by Manas Gabani's avatar Manas Gabani

Comments added, index page trend updated for classrooms, Presentation added

parent 44eadc7a
This diff is collapsed.
default_state_code = 27 # for Maharashtra
fig_size_ds_w, fig_size_ds_h = 10, 6 # width and height of distribution graphs
fig_size_tr_w, fig_size_tr_h = 8, 6 # width and height of trend graphs
form_value_to_sub_dimension_mapping = {
'govt':'Government',
'private':'Private',
......
......@@ -8,9 +8,10 @@ import matplotlib.pyplot as plt
from babel.numbers import format_number
# dict_summary={"top3":[],"bottom3":[]}
fig_size_ds_w, fig_size_ds_h = 10, 6
fig_size_tr_w, fig_size_tr_h = 8, 6
fig_size_ds_w, fig_size_ds_h = 10, 6 # width and height of distribution graphs
fig_size_tr_w, fig_size_tr_h = 8, 6 # width and height of trend graphs
# to read all raw data csv files
def read_all_csv(path='./rawdata_csv/', extension='csv'):
result = glob.glob(path+'SRC_R*.{}'.format(extension))
df=None
......@@ -30,6 +31,7 @@ def read_all_csv(path='./rawdata_csv/', extension='csv'):
return final_df
# to plot statewise distribution graphs
def statewise_distribution(output_filename, input_df, year, ylabel, main_dimension, sub_dimension=''):
dict_summary={"top3":[],"bottom3":[]}
if sub_dimension:
......@@ -65,6 +67,7 @@ def statewise_distribution(output_filename, input_df, year, ylabel, main_dimensi
return dict_summary
# to plot trend graph for enrolments
def total_enrolment_by_category(output_filename, input_df, main_dimension, state_code, ylabel):
fig = plt.figure(figsize=(fig_size_tr_w,fig_size_tr_h))
df_fil = input_df.loc[input_df['Main_Dimension'] == main_dimension]
......@@ -97,6 +100,7 @@ def total_enrolment_by_category(output_filename, input_df, main_dimension, state
plt.savefig(output_filename)
plt.close(fig)
# to plot trend graph for teachers
def total_teachers_by_main_dimension(output_filename, input_df, main_dimension, state_code):
fig = plt.figure(figsize=(fig_size_tr_w,fig_size_tr_h))
df_fil = input_df.loc[input_df['Main_Dimension'] == main_dimension]
......@@ -155,6 +159,7 @@ def total_teachers_by_main_dimension(output_filename, input_df, main_dimension,
plt.savefig(output_filename)
plt.close(fig)
# to plot trend graph for classrooms
def total_classrooms_by_trend(output_filename, input_df, state_code):
fig = plt.figure(figsize=(fig_size_tr_w,fig_size_tr_h))
df_fil=input_df.loc[input_df['Main_Dimension'] == "Total Classrooms"]
......@@ -186,6 +191,7 @@ def total_classrooms_by_trend(output_filename, input_df, state_code):
plt.savefig(output_filename)
plt.close(fig)
# to plot trend graph for facilities
def total_schools_for_facilities(output_filename, input_df, state_code):
fig = plt.figure(figsize=(fig_size_tr_w,fig_size_tr_h))
df_fil=input_df.loc[input_df['Main_Dimension'] == "School Facilities"]
......@@ -229,6 +235,7 @@ def total_schools_for_facilities(output_filename, input_df, state_code):
plt.savefig(output_filename)
plt.close(fig)
# to plot trend graph by main_dimension for index page
def main_dimension_overall(output_filename, input_df, main_dimension, ylabel):
fig = plt.figure(figsize=(fig_size_tr_w,fig_size_tr_h))
df_fil=input_df.loc[input_df['Main_Dimension'] == main_dimension]
......@@ -255,13 +262,13 @@ def main_dimension_overall(output_filename, input_df, main_dimension, ylabel):
df_major_repair = df_sum.loc[(df_sum['Sub_Dimension'] == "Need Major Repair")]
plt.plot(df_good_cond['Year'],df_good_cond['total'],marker='o',color='r', label='Good Condition')
for x, y in zip(df_good_cond['Year'],df_good_cond['total']):
plt.text(x = x, y = y, s = '{:.0f}'.format(y))
plt.text(x = x, y = y, s = '{:.0f}'.format(y), color='r', rotation=15, fontsize=7, weight='bold')
plt.plot(df_minor_repair['Year'],df_minor_repair['total'],marker='+',color='g', label='Need Minor Repair')
for x, y in zip(df_minor_repair['Year'],df_minor_repair['total']):
plt.text(x = x, y = y, s = '{:.0f}'.format(y))
plt.text(x = x, y = y, s = '{:.0f}'.format(y), color='g', rotation=15, fontsize=7, weight='bold')
plt.plot(df_major_repair['Year'],df_major_repair['total'],marker='*',color='b', label='Need Major Repair')
for x, y in zip(df_major_repair['Year'],df_major_repair['total']):
plt.text(x = x, y = y, s = '{:.0f}'.format(y))
plt.text(x = x, y = y, s = '{:.0f}'.format(y), color='b', rotation=15, fontsize=7, weight='bold')
plt.legend()
plt.title(label='KPI: ' + ylabel, fontweight='bold', fontsize=10, fontstyle='italic')
......@@ -271,6 +278,7 @@ def main_dimension_overall(output_filename, input_df, main_dimension, ylabel):
plt.savefig(output_filename)
plt.close(fig)
# to plot trend graph by school facilities for index page
def total_schools_for_facilities_overall(output_filename, input_df):
fig = plt.figure(figsize=(fig_size_tr_w,fig_size_tr_h))
df_fil=input_df.loc[input_df['Main_Dimension'] == "School Facilities"]
......@@ -312,6 +320,7 @@ def total_schools_for_facilities_overall(output_filename, input_df):
plt.savefig(output_filename)
plt.close(fig)
# to get overall card values for index page
def get_index_summary(input_df):
latest_year = max(input_df['Year'])
students = sum(input_df[(input_df['Main_Dimension']=='Elementary Enrolment by School Category') & (input_df['Year']==latest_year)]['total'])
......@@ -325,6 +334,7 @@ def get_index_summary(input_df):
'classrooms': format_number(int(classrooms), locale='en_IN')
}
# to get dimension wise card values for details page
def get_dimension_wise_summary(input_df, state_code, main_dimension):
latest_year = max(input_df['Year'])
df_fil = input_df[(input_df['State_Code']==state_code) & (input_df['Year']==latest_year)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment