포스팅 목차
3. Display the name and job for all employees.
* 전체 직원의 이름과 직업(job)을 출력하시오.
- [변수 선택] 특정 변수를 지정하여서 출력
|
1. 오라클(Oracle)
Oracle Programming |
select ename, job
from emp;
2. 파이썬(Pandas)
Python Programming |
emp[['ename', 'job']]
Results |
ename | job | |
0 | SMITH | CLERK |
1 | ALLEN | SALESMAN |
2 | WARD | SALESMAN |
3 | JONES | MANAGER |
4 | MARTIN | SALESMAN |
5 | BLAKE | MANAGER |
6 | CLARK | MANAGER |
7 | SCOTT | ANALYST |
8 | KING | PRESIDENT |
9 | TURNER | SALESMAN |
10 | ADAMS | CLERK |
11 | JAMES | CLERK |
12 | FORD | ANALYST |
13 | MILLER | CLERK |
3. R Programming (R Package)
R Programming |
%%R
emp[, c("ename","job")]
Results |
# A tibble: 14 x 2
ename job
<chr> <chr>
1 SMITH CLERK
2 ALLEN SALESMAN
3 WARD SALESMAN
4 JONES MANAGER
5 MARTIN SALESMAN
6 BLAKE MANAGER
7 CLARK MANAGER
8 SCOTT ANALYST
9 KING PRESIDENT
10 TURNER SALESMAN
11 ADAMS CLERK
12 JAMES CLERK
13 FORD ANALYST
14 MILLER CLERK
4. R Dplyr Package
R Programming |
%%R
emp %>% select(ename, job)
Results |
# A tibble: 14 x 2
ename job
<chr> <chr>
1 SMITH CLERK
2 ALLEN SALESMAN
3 WARD SALESMAN
4 JONES MANAGER
5 MARTIN SALESMAN
6 BLAKE MANAGER
7 CLARK MANAGER
8 SCOTT ANALYST
9 KING PRESIDENT
10 TURNER SALESMAN
11 ADAMS CLERK
12 JAMES CLERK
13 FORD ANALYST
14 MILLER CLERK
5. R sqldf Package
R Programming |
%%R
require(sqldf)
sqldf("select ename, job from emp")
Results |
ename job
1 SMITH CLERK
2 ALLEN SALESMAN
3 WARD SALESMAN
4 JONES MANAGER
5 MARTIN SALESMAN
6 BLAKE MANAGER
7 CLARK MANAGER
8 SCOTT ANALYST
9 KING PRESIDENT
10 TURNER SALESMAN
11 ADAMS CLERK
12 JAMES CLERK
13 FORD ANALYST
14 MILLER CLERK
6. Python pandasql Package
Python Programming |
ps.sqldf("select ename, job from emp")
Results |
ename | job | |
0 | SMITH | CLERK |
1 | ALLEN | SALESMAN |
2 | WARD | SALESMAN |
3 | JONES | MANAGER |
4 | MARTIN | SALESMAN |
5 | BLAKE | MANAGER |
6 | CLARK | MANAGER |
7 | SCOTT | ANALYST |
8 | KING | PRESIDENT |
9 | TURNER | SALESMAN |
10 | ADAMS | CLERK |
11 | JAMES | CLERK |
12 | FORD | ANALYST |
13 | MILLER | CLERK |
7. R data.table Package
R Programming |
%%R
DT <- data.table(emp)
dept_DT <- data.table(dept)
DT[ , .(ename, job)]
Results |
ename job
1: SMITH CLERK
2: ALLEN SALESMAN
3: WARD SALESMAN
4: JONES MANAGER
5: MARTIN SALESMAN
6: BLAKE MANAGER
7: CLARK MANAGER
8: SCOTT ANALYST
9: KING PRESIDENT
10: TURNER SALESMAN
11: ADAMS CLERK
12: JAMES CLERK
13: FORD ANALYST
14: MILLER CLERK
8. SAS Proc SQL
SAS Programming |
%%SAS sas
proc sql inobs=5;
select ename, job
from emp;
quit;
Results |
ename | job |
SMITH | CLERK |
ALLEN | SALESMAN |
WARD | SALESMAN |
JONES | MANAGER |
MARTIN | SALESMAN |
9. SAS Data Step
SAS Programming |
%%SAS sas
proc print data=emp;
var ename job;
run;
Results |
OBS | ename | job |
1 | SMITH | CLERK |
2 | ALLEN | SALESMAN |
3 | WARD | SALESMAN |
4 | JONES | MANAGER |
5 | MARTIN | SALESMAN |
6 | BLAKE | MANAGER |
7 | CLARK | MANAGER |
8 | SCOTT | ANALYST |
9 | KING | PRESIDEN |
10 | TURNER | SALESMAN |
11 | ADAMS | CLERK |
12 | JAMES | CLERK |
13 | FORD | ANALYST |
14 | MILLER | CLERK |
10. Python Dfply Package
- The X DataFrame symbol
Python Programming |
emp >> select(X.ename,X.job) >> head(3)
Results |
ename | job | |
0 | SMITH | CLERK |
1 | ALLEN | SALESMAN |
2 | WARD | SALESMAN |
[SQL, Pandas, R Prog, Dplyr, SQLDF, PANDASQL, DATA.TABLE] SQL EMP 예제로 만나는 테이블 데이터 처리 방법 리스트
반응형
'통계프로그램 비교 시리즈 > 프로그래밍비교(Oracle,Python,R,SAS)' 카테고리의 다른 글
[변수 생성 & 결측치 대체] 결측치 대체 후 신규 변수 생성 - 6 (0) | 2021.08.04 |
---|---|
[변수 생성] 신규 변수를 생성하여 데이터 출력 - 5 (0) | 2021.08.03 |
[변수 선택] 특정 변수를 지정하여서 데이터 출력 - 4 (0) | 2021.08.03 |
[데이터 출력] 데이터세트(테이블) 출력 - 2 (0) | 2021.08.03 |
[데이터 출력] 데이터세트(테이블) 출력 - 1 (0) | 2021.08.03 |
댓글