<jupyter_start><jupyter_text>Percent of 8 a.m Sections This code gives the number of 8 a.m sections and total number of sections in each department. Also the code calculates the percent of 8 a.m sections of total number of sections in each department.<jupyter_code>client = MongoClient('mongodb://yacsBI:yacsBIpass@mongo_db:27017/YacsDB')
db = client["YacsDB"]

departments_data = db.departments.find()
#department_lst = list()

for current_department in departments_data:
    #print("A department")
    one_department = Department(current_department)
    
        
    pprint.pprint(current_department)
    d_courses=one_department.getCourses()
    
    count=0
    d_sections=one_department.getSections()
    for sec in d_sections:
        if sec.getSecStartTime()=='08:00:00':
            count+=1;
    print("num of sections start at 8 am: ",count)
    
    print("---------------------------------------------------------------")
    #department_lst.append(one_department)
    
#print(len(department_lst))<jupyter_output>{'_id': ObjectId('5a7a1a7341957245137d8db6'),
 'code': 'ADMN',
 'id': 170,
 'name': 'Administration'}
total number of courses in  Administration  department: 72
total number of sections in this department: 43
num of sections start at 8 am:  6
---------------------------------------------------------------
{'_id': ObjectId('5a7a1a7341957245137d8db7'),
 'code': 'ARCH',
 'id': 137,
 'name': 'Architecture'}
total number of courses in  Architecture  department: 851
total number of sections in this department: 779
num of sections start at 8 am:  7
---------------------------------------------------------------
{'_id': ObjectId('5a7a1a7341957245137d8db8'),
 'code': 'ARTS',
 'id': 136,
 'name': 'Arts'}
total number of courses in  Arts  department: 750
total number of sections in this department: 616
num of sections start at 8 am:  17
---------------------------------------------------------------
{'_id': ObjectId('5a7a1a7341957245137d8db9'),
 'code': 'ASTR',
 'id': 165,
 'name': 'Astronomy'}
t[...]<jupyter_text>Average Percent of Seats TakenA sections's percent of seats taken is calculated by dividing the number of seats taken by the total number of seats in the section. And then, we calculate the average percent of seats taken of sections taught by each professor. This code gives the number of sections taught by each professor and these sections' average percent of seats taken . Also the code sorts professors by their average percent of seats taken.<jupyter_code>client = MongoClient('mongodb://yacsBI:yacsBIpass@mongo_db:27017/YacsDB')
db = client["YacsDB"]

sections_data = db.sections.find()
Prof=dict()
Prof2=dict()

scores1=list()
scores1_tuple=tuple()
profs1=list()
scores2=list()
scores2_tuple=tuple()
profs2=list()

# Prof list: {prof1:[number of sections, percent of seats taken], ...}
for current_section in sections_data:
    one_section=Section(current_section)
    prof_list=one_section.getSecProf().split("/")
    for p in prof_list:
        if(p) not in Prof.keys():
            Prof[p]=list()
            #[1]->0.0
            Prof[p]=[1,one_section.getPercentSeatsTaken()]
        n=Prof[p][0]
        Prof[p][0]+=1
        Prof[p][1]=(Prof[p][1]*n+one_section.getPercentSeatsTaken())/float(n+1)
# Prof2 list:  {prof1: percent of seats taken, ...}
for p in Prof.keys():
    #print("Professor Name:", p, "Professor Stat:",Prof[p])
    Prof2[p]=Prof[p][1]
    

    


# 30 professors with highest percent of seats taken
counter=0
for p2 in sorted(Prof2, key=Prof2.get, reverse=True):
    if(counter>29):
        break
    if(Prof[p2][0]>=20):
        print(p2, Prof[p2])
        profs1.append(p2)
        scores1.append(Prof2[p2])
        counter+=1
scores1_tuple=tuple(scores1)      

print("-----------------------------------------------------------")

# 30 professors with lowest percent of seats taken
counter=0
for p3 in sorted(Prof2, key=Prof2.get, reverse=False):
    if(counter>29):
        break
    if(Prof[p3][0]>=25):
        print(p3, Prof[p3])
        profs2.append(p3)
        scores2.append(Prof2[p3])
        counter+=1
scores2_tuple=tuple(scores2)<jupyter_output><NAME> [55, 112.05938330675174]
Hoffman [32, 104.8190103637472]
Grice [51, 103.36922098274005]
Boudjelkha [23, 103.25924377554814]
Kanai [39, 102.94871794871794]
Noble [23, 101.64476408412332]
Masterson [154, 101.22981515838657]
VerWys [39, 100.28417777367359]
Kiehl [41, 98.83178474641889]
Sturman [37, 98.74774774774775]
Haley [20, 98.73928571428571]
Traver [34, 98.24870342076223]
Schmidt [33, 97.73569023569024]
Whitburn [21, 96.85213032581454]
Lazarevic [21, 96.51159700298538]
Schierenbe [35, 96.50607533056514]
Persoon [27, 96.3741541271092]
Thero [43, 96.34835061579251]
Edick [81, 96.33058984910836]
Knowles [69, 96.16008129738105]
Puka [27, 95.03340398320904]
Stein [49, 94.94094341033119]
Steiner [181, 93.55199879923633]
Todd [22, 93.31526471612679]
Leong [53, 93.19367674500857]
Kessler [69, 93.01644812514378]
Large [29, 92.72171808832427]
Hurst [41, 92.46367273196542]
Dentz [25, 91.15175438596489]
Reid [27, 90.7994762439207]
------------------------------------------------------[...]<jupyter_text>Graph of Average Percent of Seats TakenWe get 30 professors with highest percent of seats taken. This code plots a histogram to show the results. X-axis represents professors' names, and y-axis represents the corresponding average percent of seats taken.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt

N = 30


ind = np.arange(N)  # the x locations for the groups
width = 0.5       # the width of the bars

fig, ax = plt.subplots()
Means = scores1_tuple
rects2 = ax.bar(ind + width, Means, width)

# add some text for labels, title and axes ticks
ax.set_ylabel('Percent of seats taken')
ax.set_title('Average Percent of Seats Taken ')
ax.set_xticks(ind + width)
l=profs1

ax.set_xticklabels(l,rotation=90)


plt.show()<jupyter_output><empty_output><jupyter_text>Graph of Average Percent of Seats TakenWe get 30 professors with lowest percent of seats taken. This code plots a histogram to show the results. X-axis represents professors' names, and y-axis represents the corresponding average percent of seats taken.<jupyter_code>N = 30


ind = np.arange(N)  # the x locations for the groups
width = 0.5       # the width of the bars

fig, ax = plt.subplots()
Means = scores2_tuple
rects2 = ax.bar(ind + width, Means, width)

# add some text for labels, title and axes ticks
ax.set_ylabel('Percent of seats taken')
ax.set_title('Average Percent of Seats Taken ')
ax.set_xticks(ind + width)
l=profs2

ax.set_xticklabels(l,rotation=90)


plt.show()
client = MongoClient('mongodb://yacsBI:yacsBIpass@mongo_db:27017/YacsDB')
db = client["YacsDB"]

sections_data = db.sections.find()
#{course_name:[# secs, avg seats taken],...}
Crs=dict()
Crs2=dict()

crs1=list()
avg1=list()
crs2=list()
avg2=list()

departments_data = db.departments.find()
#department_lst = list()

for current_department in departments_data:
    one_department = Department(current_department)
    course_sections=one_department.getCoursesSections()
    for CrsName in course_sections.keys():
        if CrsName not in Crs:
            Crs[CrsName]=list()
            Crs[CrsName]=[1,0.0]
        for CrsId in course_sections[CrsName].keys():
            for OneSec in course_sections[CrsName][CrsId]:
                oneSec=Section(OneSec)
                ori=Crs[CrsName][1]
                n=Crs[CrsName][0]
                Crs[CrsName][0]+=1
                Crs[CrsName][1]=(ori*n+oneSec.getPercentSeatsTaken())/float(n+1)
for c in Crs.keys():
    Crs2[c]=Crs[c][1]

    
# highest 30 courses
counter=0
for c2 in sorted (Crs2, key=Crs2.get, reverse=True):
    if(counter>29):
        break
    if(Crs[c2][0]>=20):
        print(c2, Crs[c2])
        crs1.append(c2)
        avg1.append(Crs2[c2])
        counter+=1
avg1_tuple=tuple(avg1)      
#print(crs1)
#print(avg1)
print("-----------------------------------------------------------")

# lowest 30 courses
counter=0
for c3 in sorted (Crs2, key=Crs2.get, reverse=False):
    if(counter>29):
        break
    if(Crs[c3][0]>=20):
        print(c3, Crs[c3])
        crs2.append(c3)
        avg2.append(Crs2[c3])
        counter+=1
avg2_tuple=tuple(avg2)<jupyter_output>Multidisciplinary Capstone Design [174, 100.22638812868696]
Introduction to Cell and Molecular Biology [82, 98.22493224932248]
Software Design and Documentation [36, 98.01851851851852]
Professional Development II: Leadership Theories [24, 97.02653762785341]
Professional Development III [104, 96.86213587999302]
Thermal and Fluids Engineering Laboratory [92, 96.82971014492756]
Introduction to Visual Communication [25, 95.87719298245612]
Introduction to Communication Theory [34, 94.50715022851246]
Modern Techniques in Chemistry [29, 94.42733990147782]
Introduction to Afro-Cuban Percussion [22, 94.3181818181818]
Introduction to Philosophy [24, 94.08521303258146]
Sculpture I [20, 93.87543859649122]
CALCULUS I QUIZ BLOCK [88, 92.32368326118322]
Fluid Dynamics Laboratory [53, 92.20125786163523]
Speech Communication [21, 92.09022556390977]
Beginning Programming for Engineers [58, 91.31852769004796]
Writing for Classroom and Career [25, 91.02202172096912]
Introduction to Biology [47, 90.6638025[...]
{'fraction_non_alphanumeric': 0.15722456026761628, 'fraction_numerical': 0.1240962555303766, 'mean_word_length': 3.457912457912458, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '440531', 'license': 'MIT', 'n_tokens_mistral': 3939, 'n_tokens_neox': 3163, 'n_words': 838, 'path': 'src/lyf.ipynb', 'repo_name': 'YACS-RCOS/yacs-BI', 'size': '9271'}