Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education in INDIA
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Manas
Education in INDIA
Commits
7003c622
Commit
7003c622
authored
Nov 21, 2022
by
Manas Gabani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trend routes added for facilities page
parent
38187faf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
47 deletions
+81
-47
app.py
app.py
+41
-28
static/img/trend_school_facilities_10.jpeg
static/img/trend_school_facilities_10.jpeg
+0
-0
static/img/trend_school_facilities_18.jpeg
static/img/trend_school_facilities_18.jpeg
+0
-0
static/img/trend_school_facilities_24.jpeg
static/img/trend_school_facilities_24.jpeg
+0
-0
static/img/trend_school_facilities_27.jpeg
static/img/trend_school_facilities_27.jpeg
+0
-0
templates/facilities.html
templates/facilities.html
+40
-19
No files found.
app.py
View file @
7003c622
...
...
@@ -180,6 +180,35 @@ def total_classrooms_by_trend(output_filename, input_df, state_code):
plt
.
savefig
(
output_filename
)
plt
.
close
(
fig
)
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"
]
df_fil
=
df_fil
.
loc
[(
df_fil
[
'State_Code'
]
==
state_code
)]
min_year
,
max_year
=
min
(
df_fil
[
'Year'
]),
max
(
df_fil
[
'Year'
])
df_sum
=
df_fil
.
groupby
([
'Sub_Dimension'
,
'State_Code'
,
'Year'
],
as_index
=
False
)
.
sum
()
df_sum
=
df_sum
[[
'Sub_Dimension'
,
'State_Code'
,
'Year'
,
'total'
]]
df_enrolment_lt_50
=
df_sum
.
loc
[(
df_sum
[
'Sub_Dimension'
]
==
"Enrolment <= 50"
)]
df_drinking_water
=
df_sum
.
loc
[(
df_sum
[
'Sub_Dimension'
]
==
"Schools with Drinking Water"
)]
df_girls_toilet
=
df_sum
.
loc
[(
df_sum
[
'Sub_Dimension'
]
==
"Schools with Girls' Toilet"
)]
df_ramp
=
df_sum
.
loc
[(
df_sum
[
'Sub_Dimension'
]
==
"Schools with Ramp"
)]
df_single_classroom
=
df_sum
.
loc
[(
df_sum
[
'Sub_Dimension'
]
==
"Single Classroom Schools"
)]
df_single_teacher
=
df_sum
.
loc
[(
df_sum
[
'Sub_Dimension'
]
==
"Single Teacher Schools"
)]
plt
.
plot
(
df_enrolment_lt_50
[
'Year'
],
df_enrolment_lt_50
[
'total'
],
color
=
'r'
,
label
=
'Enrolment <= 50'
)
plt
.
plot
(
df_drinking_water
[
'Year'
],
df_drinking_water
[
'total'
],
color
=
'g'
,
label
=
'Schools with Drinking Water'
)
plt
.
plot
(
df_girls_toilet
[
'Year'
],
df_girls_toilet
[
'total'
],
color
=
'b'
,
label
=
'Schools with Girls
\'
Toilet'
)
plt
.
plot
(
df_ramp
[
'Year'
],
df_ramp
[
'total'
],
color
=
'y'
,
label
=
'Schools with Ramp'
)
plt
.
plot
(
df_single_classroom
[
'Year'
],
df_single_classroom
[
'total'
],
color
=
'c'
,
label
=
'Single Classroom Schools'
)
plt
.
plot
(
df_single_teacher
[
'Year'
],
df_single_teacher
[
'total'
],
color
=
'm'
,
label
=
'Single Teacher Schools'
)
plt
.
legend
()
plt
.
xticks
(
np
.
arange
(
min_year
,
max_year
+
1
,
1.0
))
plt
.
ylabel
(
'Number of schools'
)
plt
.
xlabel
(
'Year'
)
plt
.
savefig
(
output_filename
)
plt
.
close
(
fig
)
app
=
Flask
(
__name__
)
print
(
' ------------ Server Started ------------ '
)
UPLOAD_FOLDER
=
'static/'
...
...
@@ -189,19 +218,6 @@ app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app
.
config
[
"CACHE_TYPE"
]
=
"null"
app
.
config
[
'SEND_FILE_MAX_AGE_DEFAULT'
]
=
0
def
prepare_graph
(
filename
):
data
=
list
(
np
.
random
.
uniform
(
1
,
10
,
size
=
(
10
,
1
))
.
reshape
(
-
1
))
ind
=
np
.
arange
(
len
(
data
))
# plt.ioff()
fig
=
plt
.
figure
(
figsize
=
(
8
,
6
))
plt
.
plot
(
data
,
label
=
'Number of Schools'
,
ls
=
'--'
,
color
=
'black'
,
marker
=
'o'
,
markersize
=
9
,
mew
=
2
,
linewidth
=
2
)
plt
.
xlabel
(
'Year'
)
plt
.
ylabel
(
'Number of Schools'
)
plt
.
xticks
(
ind
,
[
2000
+
i
for
i
in
ind
])
plt
.
legend
(
loc
=
0
)
plt
.
savefig
(
'./static/'
+
filename
)
plt
.
close
(
fig
)
@
app
.
after_request
def
add_header
(
request
):
"""
...
...
@@ -293,16 +309,19 @@ def classrooms():
total_classrooms_by_trend
(
os
.
path
.
join
(
app
.
config
[
'UPLOAD_FOLDER'
],
trend_classrooms
),
final_df
,
default_state_code
)
return
render_template
(
'classrooms.html'
,
trend_classrooms
=
trend_classrooms
,
distribution_classroom_by_condition
=
distribution_classroom_by_condition
,
classroom_condition_summary
=
classroom_condition_summary
,
classroom_condition
=
classroom_condition
)
trend_school_facilities
=
''
distribution_school_facility
=
''
school_facility_summary
=
{}
school_facility
=
''
@
app
.
route
(
'/facilities.html'
)
def
facilities
():
global
distribution_school_facility
,
school_facility_summary
,
school_facility
global
trend_school_facilities
,
distribution_school_facility
,
school_facility_summary
,
school_facility
school_facility
=
'Enrolment <= 50'
distribution_school_facility
=
"img/distribution_school_facility_enrolment_lt_50_{}.jpeg"
.
format
(
latest_year
)
school_facility_summary
=
statewise_distribution
(
os
.
path
.
join
(
app
.
config
[
'UPLOAD_FOLDER'
],
distribution_school_facility
),
final_df
,
latest_year
,
main_dimension
=
"School Facilities"
,
sub_dimension
=
school_facility
)
return
render_template
(
'facilities.html'
,
distribution_school_facility
=
distribution_school_facility
,
school_facility_summary
=
school_facility_summary
,
school_facility
=
school_facility
)
trend_school_facilities
=
"img/trend_school_facilities_{}.jpeg"
.
format
(
default_state_code
)
total_schools_for_facilities
(
os
.
path
.
join
(
app
.
config
[
'UPLOAD_FOLDER'
],
trend_school_facilities
),
final_df
,
default_state_code
)
return
render_template
(
'facilities.html'
,
trend_school_facilities
=
trend_school_facilities
,
distribution_school_facility
=
distribution_school_facility
,
school_facility_summary
=
school_facility_summary
,
school_facility
=
school_facility
)
# display selected image
@
app
.
route
(
'/get_card_from_index'
,
methods
=
[
'POST'
])
...
...
@@ -415,11 +434,13 @@ def get_distribution_of_classroom_conditions():
classroom_condition_summary
=
statewise_distribution
(
os
.
path
.
join
(
app
.
config
[
'UPLOAD_FOLDER'
],
distribution_classroom_by_condition
),
final_df
,
latest_year
,
main_dimension
=
"Total Classrooms"
,
sub_dimension
=
classroom_condition
)
return
render_template
(
'classrooms.html'
,
distribution_classroom_by_condition
=
distribution_classroom_by_condition
,
classroom_condition_summary
=
classroom_condition_summary
,
classroom_condition
=
classroom_condition
)
@
app
.
route
(
'/get_trend_from_facilities'
,
methods
=
[
'POST'
])
def
get_trend_from_facilities
():
trend_from_facilities
=
'img/sample_trend_facilities_new.jpeg'
prepare_graph
(
trend_from_facilities
)
return
render_template
(
'facilities.html'
,
trend_from_facilities
=
trend_from_facilities
)
@
app
.
route
(
'/get_trend_for_schools_with_facilities'
,
methods
=
[
'POST'
])
def
get_trend_for_schools_with_facilities
():
global
form_value_to_main_dimension_mapping
,
trend_school_facilities
,
distribution_school_facility
,
school_facility_summary
,
school_facility
state_code
=
int
(
request
.
form
[
'state_code'
])
trend_school_facilities
=
"img/trend_school_facilities_{}.jpeg"
.
format
(
state_code
)
total_schools_for_facilities
(
os
.
path
.
join
(
app
.
config
[
'UPLOAD_FOLDER'
],
trend_school_facilities
),
final_df
,
state_code
)
return
render_template
(
'facilities.html'
,
trend_school_facilities
=
trend_school_facilities
,
distribution_school_facility
=
distribution_school_facility
,
school_facility_summary
=
school_facility_summary
,
school_facility
=
school_facility
)
@
app
.
route
(
'/get_distribution_of_school_facilities'
,
methods
=
[
'POST'
])
def
get_distribution_of_school_facilities
():
...
...
@@ -430,13 +451,5 @@ def get_distribution_of_school_facilities():
school_facility_summary
=
statewise_distribution
(
os
.
path
.
join
(
app
.
config
[
'UPLOAD_FOLDER'
],
distribution_school_facility
),
final_df
,
latest_year
,
main_dimension
=
"School Facilities"
,
sub_dimension
=
school_facility
)
return
render_template
(
'facilities.html'
,
distribution_school_facility
=
distribution_school_facility
,
school_facility_summary
=
school_facility_summary
,
school_facility
=
school_facility
)
# # @app.route('/display/<filename>')
# @app.route('/display/<filename>')
# def display_image(filename):
# pass
# # print('display_image filename: ' + filename)
# return redirect(url_for('static', filename=filename), code=301)
if
__name__
==
"__main__"
:
app
.
run
()
\ No newline at end of file
static/img/trend_school_facilities_10.jpeg
0 → 100644
View file @
7003c622
35 KB
static/img/trend_school_facilities_18.jpeg
0 → 100644
View file @
7003c622
35 KB
static/img/trend_school_facilities_24.jpeg
0 → 100644
View file @
7003c622
34.8 KB
static/img/trend_school_facilities_27.jpeg
0 → 100644
View file @
7003c622
34.9 KB
templates/facilities.html
View file @
7003c622
...
...
@@ -78,30 +78,51 @@
<div
class=
"title"
>
Trend by state
</div>
<form
method=
"POST"
action=
"/get_trend_f
rom
_facilities"
>
<form
method=
"POST"
action=
"/get_trend_f
or_schools_with
_facilities"
>
Select state:
<select
name=
"state"
class=
"state"
>
<option
value=
"Maharashtra"
>
Maharashtra
</option>
<option
value=
"Gujarat"
>
Gujarat
</option>
<option
value=
"Karnataka"
>
Karnataka
</option>
<option
value=
"Kerela"
>
Kerela
</option>
<select
name=
"state_code"
class=
"state_code"
>
<option
value=
"1"
>
JAMMU
&
KASHMIR
</option>
<option
value=
"2"
>
HIMACHAL PRADESH
</option>
<option
value=
"3"
>
PUNJAB
</option>
<option
value=
"4"
>
CHANDIGARH
</option>
<option
value=
"5"
>
UTTARAKHAND
</option>
<option
value=
"6"
>
HARYANA
</option>
<option
value=
"7"
>
DELHI
</option>
<option
value=
"8"
>
RAJASTHAN
</option>
<option
value=
"9"
>
UTTAR PRADESH
</option>
<option
value=
"10"
>
BIHAR
</option>
<option
value=
"11"
>
SIKKIM
</option>
<option
value=
"12"
>
ARUNACHAL PRADESH
</option>
<option
value=
"13"
>
NAGALAND
</option>
<option
value=
"14"
>
MANIPUR
</option>
<option
value=
"15"
>
MIZORAM
</option>
<option
value=
"16"
>
TRIPURA
</option>
<option
value=
"17"
>
MEGHALAYA
</option>
<option
value=
"18"
>
ASSAM
</option>
<option
value=
"19"
>
WEST BENGAL
</option>
<option
value=
"20"
>
JHARKHAND
</option>
<option
value=
"21"
>
ODISHA
</option>
<option
value=
"22"
>
CHHATTISGARH
</option>
<option
value=
"23"
>
MADHYA PRADESH
</option>
<option
value=
"24"
>
GUJARAT
</option>
<option
value=
"25"
>
DAMAN
&
DIU
</option>
<option
value=
"26"
>
DADRA
&
NAGAR HAVELI
</option>
<option
value=
"27"
>
MAHARASHTRA
</option>
<option
value=
"28"
>
ANDHRA PRADESH
</option>
<option
value=
"29"
>
KARNATAKA
</option>
<option
value=
"30"
>
GOA
</option>
<option
value=
"31"
>
LAKSHADWEEP
</option>
<option
value=
"32"
>
KERALA
</option>
<option
value=
"33"
>
TAMIL NADU
</option>
<option
value=
"34"
>
PUDUCHERRY
</option>
<option
value=
"35"
>
ANDAMAN
&
NICOBAR ISLANDS
</option>
<option
value=
"36"
>
TELANGANA
</option>
</select>
Select type:
<select
name=
"type"
class=
"type"
>
<option
value=
"category"
>
By Category
</option>
<option
value=
"rural"
>
By Rural Enrolments
</option>
</select>
<input
name=
"get_trend_from_facilities"
type=
"submit"
value=
"Submit"
>
<input
name=
"get_trend_for_schools_with_facilities"
type=
"submit"
value=
"Submit"
>
</form>
{% if trend_from_facilities %}
<div>
<img
src=
"{{ url_for('static', filename=trend_from_facilities) }}"
>
</div>
{% else %}
<div>
<img
src=
"{{ url_for('static', filename=
'img/sample_trend_facilities.jpeg'
) }}"
>
<img
src=
"{{ url_for('static', filename=
trend_school_facilities
) }}"
>
</div>
{% endif %}
</div>
</div>
<div
class=
"content-2"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment