본문 바로가기
통계프로그램 비교 시리즈/오라클함수 비교(R & Python)

EXP 오라클 함수 [Oracle, Pandas, R Prog, Dplyr, Sqldf, Pandasql, Data.Table, DuckDB]

by 기서무나구물 2021. 11. 23.

포스팅 목차

    * 파이썬 & R 패키지 호출 및 예제 데이터 생성 링크


    [ EXP Oracle Function ]

     


    EXP함수는 e의 n 제곱 값을 반환한다. (e=2.71828183) 이 함수는 인수와 같은 타입의 값을 반환한다.

     

     


    1. Oracle(오라클)

     

    Oracle Programming
    SELECT EXP(4) "e to the 4th power" 
    FROM   DUAL;

     

    Results
    e to the 4th power
    ----------------------------------------------
    54.59815003314423907811026120286087840308

     


    2. Python Pandas(파이썬)

     

    Python Programming
    import math
    
    math.exp(4)

     

    Results
    54.598150033144236

     


    3. R Programming (R Package)

     

    R Programming
    %%R
    
    exp(4)

     

    Results
    [1] 54.59815

     


    4. R Dplyr Package

     

    R Programming
    %%R
    
    emp %>%
      dplyr::mutate(exp_4 = exp(4)) %>%
      head()

     

    Results
    # A tibble: 6 x 9
      empno ename  job        mgr hiredate     sal  comm deptno exp_4
      <dbl> <chr>  <chr>    <dbl> <date>     <dbl> <dbl>  <dbl> <dbl>
    1  7369 SMITH  CLERK     7902 1980-12-17   800    NA     20  54.6
    2  7499 ALLEN  SALESMAN  7698 1981-02-20  1600   300     30  54.6
    3  7521 WARD   SALESMAN  7698 1981-02-22  1250   500     30  54.6
    4  7566 JONES  MANAGER   7839 1981-04-02  2975    NA     20  54.6
    5  7654 MARTIN SALESMAN  7698 1981-09-28  1250  1400     30  54.6
    6  7698 BLAKE  MANAGER   7839 1981-03-01  2850    NA     30  54.6

     

     


    5. R sqldf Package

     

    R Programming
    %%R
    
    sqldf(" select exp(4) exp_4 ")

     

    Results
         exp_4
    1 54.59815

     

     


    6. Python pandasql Package

     

    Python Programming
    ps.sqldf(" select exp( 4) from emp  ")

     


     

    Python Programming
    import pandasql as ps
    var = math.exp(4)
    
    query = "SELECT {}  ".format(var)
    ps.sqldf(query, globals())

     

     

    Results
    	54.598150033144236
    0	54.59815​

     

     


    7. R data.table Package

     

    R Programming
    %%R
    
    DT          <- data.table(emp)
    dept_DT     <- data.table(dept)
    
    DT[, exp_4 := exp(4)][1:5, ]

     

    Results
       empno  ename      job  mgr   hiredate  sal comm deptno    exp_4
    1:  7369  SMITH    CLERK 7902 1980-12-17  800   NA     20 54.59815
    2:  7499  ALLEN SALESMAN 7698 1981-02-20 1600  300     30 54.59815
    3:  7521   WARD SALESMAN 7698 1981-02-22 1250  500     30 54.59815
    4:  7566  JONES  MANAGER 7839 1981-04-02 2975   NA     20 54.59815
    5:  7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400     30 54.59815

     


    8. Python DuckDB의 SQL

     

    Python Programming
    %%sql
      SELECT EXP(4) "e to the 4th power"

     

    Python Programming
    duckdb.sql(' SELECT EXP(4) "e to the 4th power" ').df()

     

    Results
       e to the 4th power
    0            54.59815

     

     


    Insa-dong, Jongno-gu, Seoul, South Korea (https://unsplash.com/photos/I5l81lgcRsA)

      --------------------------------------------  

     

    [Oracle, Pandas, R Prog, Dplyr, Sqldf, Pandasql, Data.Table] 오라클 함수와 R & Python 비교 사전 목록? 링크

     

    오라클 SQL 함수(Oracle SQL Function) 목록 리스트 링크

     

    [SQL, Pandas, R Prog, Dplyr, SQLDF, PANDASQL, DATA.TABLE] SQL EMP 예제로 만나는 테이블 데이터 처리 방법 리스트 링크 링크

     

    반응형

    댓글