Skip to main content

Split Schedule

Tests Status pre-commit.ci status Coverage PyPI version

This package takes a class list and reduces the number of students in each class by a specified amount. This is done by splitting the classes across days. Each individual student's day is kept the same for each of his/her classes.

The class list should be supplied as an Excel(xlsx) file with all students on a single sheet, a csv file, or a Pandas DataFrame containing the columns:

  • block = The class period as a number (i.e. 1, 2, 3, etc.)
  • class = The name of the class
  • student = The name of the student

The generated schedule will contain the fillowing columns:

  • block = The class period as a number (i.e. 1, 2, 3, etc.)
  • class = The name of the class
  • total_students = The total number of students for a block across all days
  • max_students = The maximum number of students allowed in a block each day
  • num_classes = The total number of days needed in order to allow for the maximum class size
  • day_number = The day for the class. This can be used as desired. For example 1 = Monday, 2 = Tuesday, etc.
  • student = The name of the student

Installation

Note: Python 3.8 or greater is required

Using a virtual environmnet is recommended for installing this package. Once the virtual environment is created and activated install the package with:

pip install split-schedule

Usage

ScheduleBuilder Methods

  • build_schedule_from_df: Builds the schedule from a Pandas DataFrame
    • df: The DataFrame that contains the schedule to split
    • reduce_by (optinal): The amount by which the class size should be reduced. Default = 0.2
    • smallest_allowed (optinal): The smallest a class should be. This can be used to override the reduce_by amount in cases where the class would be smaller than the desired amount. For example if classes are being reduced 50% (0.5) if the smallest allowd class is 10 and a class has 10 students at the start, then all 10 of these students would be kept in one class rather than reducing the size below 10. Default = 1
    • max_tries (optinal): The maximum number of times the program will restart itself tying to find a viable schedule. If the maximum number of tries is exceded with no viable schedule found a SchedulingError error will occur meaning no possible way was found to split the schedule with parameters supplied. Default = 10
    • verbose (optinal): Setting verbose to True will result in log output being written to the terminal as the schedule is being build. Default = False
  • build_schedule_from_file: Builds the schedule from either an Excel(xlsx) file or a csv file.
    • schedule_file_path: The path to the schedule file, including the name of the file. The file path can be either a string or a Path object. Excel files in xlsx format or csv files are accepted.
    • reduce_by (optinal): The amount by which the class size should be reduced. Default = 0.2
    • smallest_allowed (optinal): The smallest a class should be. This can be used to override the reduce_by amount in cases where the class would be smaller than the desired amount. For example if classes are being reduced 50% (0.5) if the smallest allowd class is 10 and a class has 10 students at the start, then all 10 of these students would be kept in one class rather than reducing the size below 10. Default = 1
    • max_tries (optinal): The maximum number of times the program will restart itself tying to find a viable schedule. If the maximum number of tries is exceded with no viable schedule found a SchedulingError error will occur meaning no possible way was found to split the schedule with parameters supplied. Default = 10
    • verbose (optinal): Setting verbose to True will result in log output being written to the terminal as the schedule is being build. Default = False
  • save_schedule: Saves the generated schedule to a file.
    • save_path: The path to which the generated schedule file should be saved, including the desired name of the file. The file path can be either a string or a Path object. Excel files in xlsx format or csv files are accepted.

ScheduleBuilder Properties

  • final_schedule_df: This is a Pandas DataFrame that contains the generated schedule. Before the schedule is created the property will be None

Examples

Note: Examples uses Mac/Linux type file paths. For Windows use paths like c:\path\to\original_file.xlsx and c:\path\to\generated_schedule.xlsx.

Create a schedule from an Excel file, then save the generated schedule to another Excel file.

from split_schedule import ScheduleBuilder

schedule_builder = ScheduleBuilder()
schedule_builder.build_schedule_from_file("/path/to/file.xlsx")
schedule_builder.save_schedule("/path/to/generated_schedule.xlsx")

Create a schedule from an Excel file, then print the resulting schedule DataFrame.

from split_schedule import ScheduleBuilder

schedule_builder = ScheduleBuilder()
schedule_builder.build_schedule_from_file("/path/to/file.xlsx")
print(schedule_builder.final_schedule_df)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

split-schedule-0.3.3.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

split_schedule-0.3.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file split-schedule-0.3.3.tar.gz.

File metadata

  • Download URL: split-schedule-0.3.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.4 Linux/5.4.0-1043-azure

File hashes

Hashes for split-schedule-0.3.3.tar.gz
Algorithm Hash digest
SHA256 8c5249e59e5ba38f71e104020eec26113f69148639c65ecfacf760d1ba61463c
MD5 5d8f306a68743caf7667ac1fef70a39c
BLAKE2b-256 8c76a29a7022bd9ccacf44689557665c94043a175f677c4e31b71656c4a1d675

See more details on using hashes here.

File details

Details for the file split_schedule-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: split_schedule-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.4 Linux/5.4.0-1043-azure

File hashes

Hashes for split_schedule-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af1063a5439e110296b19b0e82e60b4e3a69c079ffb12ccb342be2c85a573c39
MD5 a05bf22d84e9e6fe7a8f3dc74ae7c6a8
BLAKE2b-256 25ea0ceac9571f8f2321de1a93a5086c9c7c4c277e484f5e77d5d903eb28371f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.5

2 files

0.3.4

2 files

This release

0.3.3 This release

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page