Rutgers courses

The Rutgers course catalog, for a given term, are given on the website: https://classes.rutgers.edu/soc/#courses?subject=960&semester=92024&campus=NB&level=G

Inspecting the requests made from the webpage quickly reveals API requests of the form https://classes.rutgers.edu/soc/api/courses.json?year=2024&term=9&campus=NB

import pandas as pd
import requests

response = requests.get('https://classes.rutgers.edu/soc/api/courses.json?year=2024&term=9&campus=NB')
response
<Response [200]>
response.json()[0]
{'campusLocations': [{'code': '1', 'description': 'College Avenue'}],
 'subject': '013',
 'openSections': 1,
 'synopsisUrl': 'https://www.amesall.rutgers.edu/academics/undergraduate-program/course-descriptions',
 'title': 'BIBLE IN ARAMAIC',
 'preReqNotes': '',
 'courseString': '01:013:111',
 'school': {'code': '01', 'description': 'School of Arts and Sciences'},
 'credits': 3,
 'subjectDescription': 'African, Middle Eastern, and South Asian Languages and Literatures',
 'coreCodes': [{'id': '2024901013111  17',
   'year': '2024',
   'term': '9',
   'effective': '20249',
   'coreCodeReferenceId': '17',
   'coreCode': 'AHp',
   'coreCodeDescription': 'Arts and Literatures',
   'description': 'Arts and Literatures',
   'code': 'AHp',
   'unit': '01',
   'course': '111',
   'subject': '013',
   'offeringUnitCode': '01',
   'offeringUnitCampus': 'NB',
   'supplement': '  ',
   'lastUpdated': 1468423733000},
  {'id': '2024901013111  20',
   'year': '2024',
   'term': '9',
   'effective': '20249',
   'coreCodeReferenceId': '20',
   'coreCode': 'HST',
   'coreCodeDescription': 'Historical Analysis',
   'description': 'Historical Analysis',
   'code': 'HST',
   'unit': '01',
   'course': '111',
   'subject': '013',
   'offeringUnitCode': '01',
   'offeringUnitCampus': 'NB',
   'supplement': '  ',
   'lastUpdated': 1468423759000}],
 'expandedTitle': 'THE BIBLE IN ARAMAIC                                                            ',
 'mainCampus': 'NB',
 'subjectNotes': '',
 'courseNumber': '111',
 'creditsObject': {'code': '3_0', 'description': '3.0 credits'},
 'level': 'U',
 'campusCode': 'NB',
 'subjectGroupNotes': '',
 'offeringUnitCode': '01',
 'offeringUnitTitle': None,
 'courseDescription': '',
 'sections': [{'sectionEligibility': '',
   'sessionDatePrintIndicator': 'N',
   'examCode': 'C',
   'specialPermissionAddCode': None,
   'crossListedSections': [{'courseNumber': '123',
     'supplementCode': '  ',
     'sectionNumber': '01',
     'offeringUnitCampus': 'NB',
     'primaryRegistrationIndex': '05957',
     'offeringUnitCode': '01',
     'registrationIndex': '05959',
     'subjectCode': '840'},
    {'courseNumber': '146',
     'supplementCode': '  ',
     'sectionNumber': '01',
     'offeringUnitCampus': 'NB',
     'primaryRegistrationIndex': '05957',
     'offeringUnitCode': '01',
     'registrationIndex': '05958',
     'subjectCode': '563'}],
   'sectionNotes': 'IN ENGLISH, CREDIT NOT GIVEN FORTHIS COURSE 01:563:146 OR01:840:123',
   'specialPermissionDropCode': None,
   'crossListedSectionType': '2',
   'instructors': [{'name': 'HABERL, CHARLES'}],
   'number': '01',
   'majors': [],
   'openToText': '',
   'openStatusText': 'OPEN',
   'sessionDates': None,
   'specialPermissionDropCodeDescription': None,
   'subtopic': '',
   'courseFeeDescr': None,
   'openStatus': True,
   'comments': [{'code': '05',
     'description': 'Go to http://canvas.rutgers.edu'}],
   'instructorsText': 'HABERL, CHARLES',
   'minors': [],
   'examCodeText': 'During class hour',
   'campusCode': 'NB',
   'sectionCampusLocations': [{'code': '1', 'description': 'College Avenue'}],
   'index': '05957',
   'unitMajors': [],
   'printed': 'Y',
   'specialPermissionAddCodeDescription': None,
   'courseFee': '0000.00',
   'commentsText': 'Go to http://canvas.rutgers.edu',
   'subtitle': '',
   'crossListedSectionsText': '01:840:123:01 (05959), 01:563:146:01 (05958)',
   'sectionCourseType': 'T',
   'meetingTimes': [{'campusLocation': '1',
     'roomNumber': '120',
     'campusAbbrev': 'CAC',
     'campusName': 'COLLEGE AVENUE',
     'startTimeMilitary': '1400',
     'buildingCode': 'SC',
     'meetingModeDesc': 'LEC',
     'endTimeMilitary': '1520',
     'meetingModeCode': '02',
     'baClassHours': '',
     'pmCode': 'P',
     'meetingDay': 'T',
     'startTime': '0200',
     'endTime': '0320'},
    {'campusLocation': '1',
     'roomNumber': '120',
     'campusAbbrev': 'CAC',
     'campusName': 'COLLEGE AVENUE',
     'startTimeMilitary': '1400',
     'buildingCode': 'SC',
     'meetingModeDesc': 'LEC',
     'endTimeMilitary': '1520',
     'meetingModeCode': '02',
     'baClassHours': '',
     'pmCode': 'P',
     'meetingDay': 'H',
     'startTime': '0200',
     'endTime': '0320'}],
   'legendKey': None,
   'honorPrograms': []}],
 'supplementCode': '  ',
 'unitNotes': '',
 'courseNotes': ''}

Parsing individual fields

response.json()[0]['mainCampus']
'NB'
response.json()[0]['sections'][0]['instructorsText']
'HABERL, CHARLES'
response.json()[0]['sections'][0]['meetingTimes'][0]['meetingDay']
'T'
response.json()[0]['sections'][0]['meetingTimes'][0]['startTime']
'0200'
response.json()[0]['sections'][0]['meetingTimes'][0]['endTime']
'0320'
response.json()[0]['level']
'U'
response.json()[0]['title']
'BIBLE IN ARAMAIC'
response.json()[0]['expandedTitle']
'THE BIBLE IN ARAMAIC                                                            '

Constructing a pandas df

data = []
for course in response.json():
    for section in course['sections']:
        d = dict(title=course['expandedTitle'],
                 level=course['level'],
                 instructor=section['instructorsText'],
                 courseString=course['courseString'],
                 meeting1day=section['meetingTimes'][0]['meetingDay'],
                 meeting1startTime=section['meetingTimes'][0]['startTime'],
                 meeting1endTime=section['meetingTimes'][0]['endTime'],
                 course=course['courseNumber'],
                 subject=course['subject'],
                 school_code=course['school']['code'],
                 school=course['school']['description']
        )
        if len(section['meetingTimes']) >= 2:
            d['meeting2day'] = section['meetingTimes'][1]['meetingDay']
            d['meeting2startTime'] = section['meetingTimes'][1]['startTime']
            d['meeting2endTime'] = section['meetingTimes'][1]['endTime']
        data.append(d)
df = pd.DataFrame(data)
df.head()
title level instructor courseString meeting1day meeting1startTime meeting1endTime course subject school_code school meeting2day meeting2startTime meeting2endTime
0 THE BIBLE IN ARAMAIC ... U HABERL, CHARLES 01:013:111 T 0200 0320 111 013 01 School of Arts and Sciences H 0200 0320
1 LITERARY EGYPT ... U SELIM, SAMAH 01:013:120 T 0200 0320 120 013 01 School of Arts and Sciences H 0200 0320
2 COMICS IN THE MIDDLE EAST ... U KOERBER 01:013:130 M 0540 0700 130 013 01 School of Arts and Sciences W 0540 0700
3 ELEMENTARY ARABIC I ... U HABBAL, MANAR 01:013:140 T 0200 0320 140 013 01 School of Arts and Sciences H 0200 0320
4 ELEMENTARY ARABIC I ... U HABBAL, MANAR 01:013:140 T 0540 0700 140 013 01 School of Arts and Sciences H 0540 0700

Filtering using pandas

df.loc[df.subject == '954', :]
title level instructor courseString meeting1day meeting1startTime meeting1endTime course subject school_code school meeting2day meeting2startTime meeting2endTime
9797 STATISTICAL LEARNING FOR DATA SCIENCE ... G BELLEC, PIERRE 16:954:534 M 0600 0900 534 954 16 The School of Graduate Studies - New Brunswick NaN NaN NaN
9798 STATISTICAL LEARNING FOR DATA SCIENCE ... G MORAN, GEMMA 16:954:534 T 0350 0510 534 954 16 The School of Graduate Studies - New Brunswick H 0350 0510
9799 ADVANCED ANALYTICS USING STATISTICAL SOFTWARE ... G JOHN, AJITA 16:954:577 T 0600 0900 577 954 16 The School of Graduate Studies - New Brunswick NaN NaN NaN
9800 PROBABILITY AND STATISTICAL INFERENCE FOR DATA... G ZHANG, LINJUN 16:954:581 H 0600 0900 581 954 16 The School of Graduate Studies - New Brunswick NaN NaN NaN
9801 PROBABILITY AND STATISTICAL INFERENCE FOR DATA... G ZHANG, LINJUN 16:954:581 H 0600 0900 581 954 16 The School of Graduate Studies - New Brunswick NaN NaN NaN
9802 PROBABILITY AND STATISTICAL INFERENCE FOR DATA... G LUVALLE 16:954:581 M 0200 0320 581 954 16 The School of Graduate Studies - New Brunswick W 0200 0320
9803 REGRESSION AND TIME SERIES ANALYSIS FOR DATA S... G GONG, RUOBIN 16:954:596 M 1020 1140 596 954 16 The School of Graduate Studies - New Brunswick H 1020 1140
9804 REGRESSION AND TIME SERIES ANALYSIS FOR DATA S... G MARDEKIAN, JACK 16:954:596 M 0600 0900 596 954 16 The School of Graduate Studies - New Brunswick NaN NaN NaN
9805 INDEPENDENT STUDIES IN THE APPLICATION OF DATA... G 16:954:683 683 954 16 The School of Graduate Studies - New Brunswick NaN NaN NaN
9806 PRACTICAL TRAINING IN STATISTICS FOR DATA SCIE... G 16:954:690 690 954 16 The School of Graduate Studies - New Brunswick NaN NaN NaN

Interactive dataframe (interaction possible in a quarto website)

from itables import show
show(df, maxBytes=0)
title level instructor courseString meeting1day meeting1startTime meeting1endTime course subject school_code school meeting2day meeting2startTime meeting2endTime
Loading... (need help?)