포스팅 목차
2. Display the details of all employees.
* 2. Emp 테이블을 출력하시오.
- 데이터세트(테이블) 출력
|
1. 오라클(Oracle)
Oracle Programming |
select *
from emp;
2. 파이썬(Pandas)
Python Programming |
display(emp)
Results |
empno | ename | job | mgr | hiredate | sal | comm | deptno | Tot_salary | annualsal | |
0 | 7369 | SMITH | CLERK | 7902.0 | 1980/12/17 | 800 | NaN | 20 | NaN | 9600.0 |
1 | 7499 | ALLEN | SALESMAN | 7698.0 | 1981/02/20 | 1600 | 300.0 | 30 | 480000.0 | 19500.0 |
2 | 7521 | WARD | SALESMAN | 7698.0 | 1981/02/22 | 1250 | 500.0 | 30 | 625000.0 | 15500.0 |
3 | 7566 | JONES | MANAGER | 7839.0 | 1981/04/02 | 2975 | NaN | 20 | NaN | 35700.0 |
4 | 7654 | MARTIN | SALESMAN | 7698.0 | 1981/09/28 | 1250 | 1400.0 | 30 | 1750000.0 | 16400.0 |
5 | 7698 | BLAKE | MANAGER | 7839.0 | 1981/03/01 | 2850 | NaN | 30 | NaN | 34200.0 |
6 | 7782 | CLARK | MANAGER | 7839.0 | 1981/01/09 | 2450 | NaN | 10 | NaN | 29400.0 |
7 | 7788 | SCOTT | ANALYST | 7566.0 | 1982/12/09 | 3000 | NaN | 20 | NaN | 36000.0 |
8 | 7839 | KING | PRESIDENT | NaN | 1981/11/17 | 5000 | NaN | 10 | NaN | 60000.0 |
9 | 7844 | TURNER | SALESMAN | 7698.0 | 1981/09/08 | 1500 | 0.0 | 30 | 0.0 | 18000.0 |
10 | 7876 | ADAMS | CLERK | 7788.0 | 1983/01/12 | 1100 | NaN | 20 | NaN | 13200.0 |
11 | 7900 | JAMES | CLERK | 7698.0 | 1981/12/03 | 950 | NaN | 30 | NaN | 11400.0 |
12 | 7902 | FORD | ANALYST | 7566.0 | 1981/12/03 | 3000 | NaN | 20 | NaN | 36000.0 |
13 | 7934 | MILLER | CLERK | 7782.0 | 1982/01/23 | 1300 | NaN | 10 | NaN | 15600.0 |
3. R Programming (R Package)
R Programming |
%%R
print(emp)
Results |
# A tibble: 14 x 10
empno ename job mgr hiredate sal comm deptno Tot_salary
<dbl> <chr> <chr> <dbl> <date> <dbl> <dbl> <dbl> <dbl>
1 7369 SMITH CLERK 7902 1980-12-17 800 NA 20 NA
2 7499 ALLEN SALE~ 7698 1981-02-20 1600 300 30 480000
3 7521 WARD SALE~ 7698 1981-02-22 1250 500 30 625000
4 7566 JONES MANA~ 7839 1981-04-02 2975 NA 20 NA
5 7654 MART~ SALE~ 7698 1981-09-28 1250 1400 30 1750000
6 7698 BLAKE MANA~ 7839 1981-03-01 2850 NA 30 NA
7 7782 CLARK MANA~ 7839 1981-01-09 2450 NA 10 NA
8 7788 SCOTT ANAL~ 7566 1982-12-09 3000 NA 20 NA
9 7839 KING PRES~ NA 1981-11-17 5000 NA 10 NA
10 7844 TURN~ SALE~ 7698 1981-09-08 1500 0 30 0
11 7876 ADAMS CLERK 7788 1983-01-12 1100 NA 20 NA
12 7900 JAMES CLERK 7698 1981-12-03 950 NA 30 NA
13 7902 FORD ANAL~ 7566 1981-12-03 3000 NA 20 NA
14 7934 MILL~ CLERK 7782 1982-01-23 1300 NA 10 NA
# ... with 1 more variable: annualsal$sal <dbl>
4. R Dplyr Package
R Programming |
%%R
emp %>% print()
Results |
# A tibble: 14 x 8
empno ename job mgr hiredate sal comm deptno
<dbl> <chr> <chr> <dbl> <date> <dbl> <dbl> <dbl>
1 7369 SMITH CLERK 7902 1980-12-17 800 NA 20
2 7499 ALLEN SALESMAN 7698 1981-02-20 1600 300 30
3 7521 WARD SALESMAN 7698 1981-02-22 1250 500 30
4 7566 JONES MANAGER 7839 1981-04-02 2975 NA 20
5 7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400 30
6 7698 BLAKE MANAGER 7839 1981-03-01 2850 NA 30
7 7782 CLARK MANAGER 7839 1981-01-09 2450 NA 10
8 7788 SCOTT ANALYST 7566 1982-12-09 3000 NA 20
9 7839 KING PRESIDENT NA 1981-11-17 5000 NA 10
10 7844 TURNER SALESMAN 7698 1981-09-08 1500 0 30
11 7876 ADAMS CLERK 7788 1983-01-12 1100 NA 20
12 7900 JAMES CLERK 7698 1981-12-03 950 NA 30
13 7902 FORD ANALYST 7566 1981-12-03 3000 NA 20
14 7934 MILLER CLERK 7782 1982-01-23 1300 NA 10
5. R sqldf Package
R Programming |
%%R
require(sqldf)
sqldf("select * from emp")
Results |
empno ename job mgr hiredate sal comm deptno
1 7369 SMITH CLERK 7902 1980-12-17 800 NA 20
2 7499 ALLEN SALESMAN 7698 1981-02-20 1600 300 30
3 7521 WARD SALESMAN 7698 1981-02-22 1250 500 30
4 7566 JONES MANAGER 7839 1981-04-02 2975 NA 20
5 7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400 30
6 7698 BLAKE MANAGER 7839 1981-03-01 2850 NA 30
7 7782 CLARK MANAGER 7839 1981-01-09 2450 NA 10
8 7788 SCOTT ANALYST 7566 1982-12-09 3000 NA 20
9 7839 KING PRESIDENT NA 1981-11-17 5000 NA 10
10 7844 TURNER SALESMAN 7698 1981-09-08 1500 0 30
11 7876 ADAMS CLERK 7788 1983-01-12 1100 NA 20
12 7900 JAMES CLERK 7698 1981-12-03 950 NA 30
13 7902 FORD ANALYST 7566 1981-12-03 3000 NA 20
14 7934 MILLER CLERK 7782 1982-01-23 1300 NA 10
6. Python pandasql Package
Python Programming |
import pandasql as ps
ps.sqldf("select * from emp")
Results |
empno | ename | job | mgr | hiredate | sal | comm | deptno | |
0 | 7369 | SMITH | CLERK | 7902.0 | 1980/12/17 | 800 | NaN | 20 |
1 | 7499 | ALLEN | SALESMAN | 7698.0 | 1981/02/20 | 1600 | 300.0 | 30 |
2 | 7521 | WARD | SALESMAN | 7698.0 | 1981/02/22 | 1250 | 500.0 | 30 |
3 | 7566 | JONES | MANAGER | 7839.0 | 1981/04/02 | 2975 | NaN | 20 |
4 | 7654 | MARTIN | SALESMAN | 7698.0 | 1981/09/28 | 1250 | 1400.0 | 30 |
5 | 7698 | BLAKE | MANAGER | 7839.0 | 1981/03/01 | 2850 | NaN | 30 |
6 | 7782 | CLARK | MANAGER | 7839.0 | 1981/01/09 | 2450 | NaN | 10 |
7 | 7788 | SCOTT | ANALYST | 7566.0 | 1982/12/09 | 3000 | NaN | 20 |
8 | 7839 | KING | PRESIDENT | NaN | 1981/11/17 | 5000 | NaN | 10 |
9 | 7844 | TURNER | SALESMAN | 7698.0 | 1981/09/08 | 1500 | 0.0 | 30 |
10 | 7876 | ADAMS | CLERK | 7788.0 | 1983/01/12 | 1100 | NaN | 20 |
11 | 7900 | JAMES | CLERK | 7698.0 | 1981/12/03 | 950 | NaN | 30 |
12 | 7902 | FORD | ANALYST | 7566.0 | 1981/12/03 | 3000 | NaN | 20 |
13 | 7934 | MILLER | CLERK | 7782.0 | 1982/01/23 | 1300 | NaN | 10 |
7. R data.table Package
R Programming |
%%R
DT <- data.table(emp)
dept_DT <- data.table(dept)
DT
Results |
empno ename job mgr hiredate sal comm deptno
1: 7369 SMITH CLERK 7902 1980-12-17 800 NA 20
2: 7499 ALLEN SALESMAN 7698 1981-02-20 1600 300 30
3: 7521 WARD SALESMAN 7698 1981-02-22 1250 500 30
4: 7566 JONES MANAGER 7839 1981-04-02 2975 NA 20
5: 7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400 30
6: 7698 BLAKE MANAGER 7839 1981-03-01 2850 NA 30
7: 7782 CLARK MANAGER 7839 1981-01-09 2450 NA 10
8: 7788 SCOTT ANALYST 7566 1982-12-09 3000 NA 20
9: 7839 KING PRESIDENT NA 1981-11-17 5000 NA 10
10: 7844 TURNER SALESMAN 7698 1981-09-08 1500 0 30
11: 7876 ADAMS CLERK 7788 1983-01-12 1100 NA 20
12: 7900 JAMES CLERK 7698 1981-12-03 950 NA 30
13: 7902 FORD ANALYST 7566 1981-12-03 3000 NA 20
14: 7934 MILLER CLERK 7782 1982-01-23 1300 NA 10
8. SAS Proc SQL
SAS Programming |
%%SAS sas
proc sql inobs=5;
select *
from emp;
quit;
Results |
empno | ename | job | mgr | hiredate | sal | comm | deptno |
7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800 | . | 20 |
7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600 | 300 | 30 |
7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250 | 500 | 30 |
7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975 | . | 20 |
7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250 | 1400 | 30 |
9. SAS Data Step
SAS Programming |
%%SAS sas
proc print data=emp;
run;
Results |
OBS | empno | ename | job | mgr | hiredate | sal | comm | deptno |
1 | 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800 | . | 20 |
2 | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600 | 300 | 30 |
3 | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250 | 500 | 30 |
4 | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975 | . | 20 |
5 | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250 | 1400 | 30 |
6 | 7698 | BLAKE | MANAGER | 7839 | 1981-03-01 | 2850 | . | 30 |
7 | 7782 | CLARK | MANAGER | 7839 | 1981-01-09 | 2450 | . | 10 |
8 | 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000 | . | 20 |
9 | 7839 | KING | PRESIDEN | . | 1981-11-17 | 5000 | . | 10 |
10 | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500 | 0 | 30 |
11 | 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100 | . | 20 |
12 | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950 | . | 30 |
13 | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000 | . | 20 |
14 | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300 | . | 10 |
10. Python Dfply Package
Python Programming |
display(emp >> head(5))
Results |
empno | ename | job | mgr | hiredate | sal | comm | deptno | |
0 | 7369 | SMITH | CLERK | 7902.0 | 1980/12/17 | 800 | NaN | 20 |
1 | 7499 | ALLEN | SALESMAN | 7698.0 | 1981/02/20 | 1600 | 300.0 | 30 |
2 | 7521 | WARD | SALESMAN | 7698.0 | 1981/02/22 | 1250 | 500.0 | 30 |
3 | 7566 | JONES | MANAGER | 7839.0 | 1981/04/02 | 2975 | NaN | 20 |
4 | 7654 | MARTIN | SALESMAN | 7698.0 | 1981/09/28 | 1250 | 1400.0 | 30 |
[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 |
[변수 선택] 특정 변수를 지정하여서 데이터 출력 - 3 (0) | 2021.08.03 |
[데이터 출력] 데이터세트(테이블) 출력 - 1 (0) | 2021.08.03 |
댓글