当前位置: 首页>>代码示例>>Python>>正文


Python Course.add方法代码示例

本文整理汇总了Python中course.Course.add方法的典型用法代码示例。如果您正苦于以下问题:Python Course.add方法的具体用法?Python Course.add怎么用?Python Course.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在course.Course的用法示例。


在下文中一共展示了Course.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_courses

# 需要导入模块: from course import Course [as 别名]
# 或者: from course.Course import add [as 别名]
def create_courses(roster_data, keep_df=None):
    """
    Create Course objects by doing one pass of roster file and using info from fields
    StudentID, coursename, TeacherID. Based on the 'keeplist', determine whether a course in mandatry

    Return data frame with new column that contains list of Course objects
    """

    # Track courses (Course objects) that are created; will eventually be added to main roster dataframe
    course_list = []

    for ix, row in roster_data.iterrows():

        # Info for the course
        sid = row["StudentID"]
        course = row["coursename"]
        teachID = row["TeacherID"]
        subject = row["subject"]

        # Does Course already exist
        exists = False
        for course_obj in course_list:
            course_name = course_obj.course_name
            teach_id = course_obj.teacher_id

            if course == course_name and teachID == teach_id:
                course_obj.add(sid)
                course_list.append(course_obj)
                exists = True
                break

        # Continue if course existed
        if exists:
            continue
        else:

            # Check if there is a keep list and, if so, check if this course shoudl be listed as mandatory
            keep = False
            if isinstance(keep_df, pd.DataFrame):
                if course in keep_df["coursename"].tolist() or subject in keep_df["subject"].tolist():
                    keep = True

            # Create new course
            new_course = Course(course, teachID, subject, keep)
            new_course.add(sid)

            course_list.append(new_course)

    roster_data["Course"] = course_list
    return roster_data
开发者ID:jbg24,项目名称:SurveyAdmin,代码行数:52,代码来源:sample.py


注:本文中的course.Course.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。