You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

学院教职工职称因子归一化去重并合并为单一列表

How to Extract Unique Faculty Titles & Consolidate Specific Categories

Got it, let's break down how to solve this problem—whether you're using a data processing library like pandas (great for larger datasets) or just plain Python for simpler lists, I've got you covered.

If your faculty data is in a dataframe (like from a CSV/Excel file), pandas makes this straightforward:

  1. Import pandas and load your data

    import pandas as pd
    
    # Replace this with your actual data loading code (e.g., pd.read_csv("faculty_data.csv"))
    sample_data = {
        "Name": ["Alice Smith", "Bob Jones", "Charlie Brown", "Diana Lee", "Eve Adams"],
        "Title": ["Professor", "Distinguished Professor", "Assistant Teaching Professor", "Instructor", "Professor"]
    }
    df = pd.DataFrame(sample_data)
    
  2. Standardize titles to merge categories
    Create a mapping to reclassify "Distinguished Professor" as "Professor", then apply it to your title column:

    title_consolidation = {
        "Distinguished Professor": "Professor"
        # Add more key-value pairs here if you need to merge other titles later
    }
    
    df["Standardized_Title"] = df["Title"].replace(title_consolidation)
    
  3. Extract unique standardized titles
    Use unique() to get distinct values, then convert to a list for readability:

    unique_standardized_titles = df["Standardized_Title"].unique().tolist()
    print(unique_standardized_titles)
    

    Output:

    ['Professor', 'Assistant Teaching Professor', 'Instructor']
    

Pure Python Approach (For Simple Lists)

If you're working with a basic list of titles instead of a dataframe, this method works perfectly:

# Your raw list of faculty titles (replace with your actual data)
raw_titles = ["Professor", "Distinguished Professor", "Assistant Teaching Professor", "Instructor", "Professor"]

# Define the consolidation rule
title_mapping = {"Distinguished Professor": "Professor"}

# Standardize each title
standardized_titles = [title_mapping.get(title, title) for title in raw_titles]

# Get unique values (convert to set first, then back to list)
unique_titles = list(set(standardized_titles))
# Optional: sort the list alphabetically
unique_titles.sort()

print(unique_titles)

Output:

['Assistant Teaching Professor', 'Instructor', 'Professor']

Both methods will give you the unique, consolidated titles you need. Adjust the mapping dictionary if you ever need to merge additional title categories later!

内容的提问来源于stack exchange,提问作者Kuai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:54:47