7.4 结构化数据排名

 

7.3 序列排名


1. 单字段排名

2. 多字段排名

SPL

A B
1 =file(“EMPLOYEE.csv”).import@tc()
2 =A1.ranks(BIRTHDAY) / 出生日期升序排名
3 =A1.ranks([BIRTHDAY,-HIREDATE]) / 出生日期升序, 入职时间降序排名

SQL

1. 单字段排名

SELECT RANK() OVER (ORDER BY BIRTHDAY) AS rank
FROM EMPLOYEE
ORDER BY ROWNUM;

2. 多字段排名

SELECT RANK() OVER (ORDER BY BIRTHDAY ASC,HIREDATE DESC) AS rank
FROM (SELECT * FROM EMPLOYEE ORDER BY EID)
ORDER BY ROWNUM;

Python

df = pd.read_csv('../EMPLOYEE.csv')
#出生日期升序排名
birthday_ascending_rank = df['BIRTHDAY'].rank(ascending=True,method='min').values 

Python 不支持多字段排名,想完成这一任务只能硬编码。


7.5 转置
SPL SQL Python 代码示例对比