【对比Python】外键关联2

任务:找出部门经理最年轻的部门

Python

1 import pandas as pd
2 import datetime
3 emp_file = "E:/txt/EMPLOYEE.txt"
4 manager_file = "E:/txt/DEPARTMENT.txt"
5 emp_info = pd.read_csv(emp_file,sep='\t')
6 manager_info = pd.read_csv(manager_file,sep='\t')
7 manager_join = pd.merge(manager_info,emp_info,left_on='MANAGER',right_on='EID')
8 today = datetime.datetime.today().year
9 arr = pd.to_datetime(manager_join['BIRTHDAY'])
10 manager_join['AGE'] = today-arr.dt.year
11 min_age = manager_join['AGE'].min()
12 young = manager_join[manager_join['AGE']==min_age]['DEPT']
13 print(young)

集算器

  A
1 =file("E:/txt/EMPLOYEE.txt").import@t()
2 =file("E:/txt/DEPARTMENT.txt").import@t()
3 =A2.join(MANAGER,A1:EID,~:manager)
4 =A3.minp(manager.(age(BIRTHDAY))).manager.DEPT

同样是外键对象化的应用。