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

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

by 기서무나구물 2021. 12. 18.

포스팅 목차

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


    [ SINH Oracle Function ]

     


    SINH함수는 지정한 인수 n의 쌍곡선 사인(hyperbolic sine) 값을 반환한다.

     

     

     


    1. Oracle(오라클)

     

    sinh() 함수

    Oracle Programming
    SELECT SINH(1) 
    FROM   DUAL

     

    Results
    SINH(1)
    -----------------------------------------
    1.17520119364380145688238185059560081516

     


    2. Python Pandas(파이썬)

     

    math.sinh() 함수

    Python Programming
    import math
    math.sinh(1)

     

    Results
    1.1752011936438014

     

     

     


    3. R Programming (R Package)

     

    sinh() 함수

    R Programming
    %%R
    
    sinh(1)

     

    Results
    [1] 1.175201

     

     

     


    4. R Dplyr Package

     

    sinh() 함수

    R Programming
    %%R
    
    emp %>%
      dplyr::mutate(sinh = sinh(deptno/10)) %>%
      head()

     

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

     

     

     


    5. R sqldf Package

     

    sinh() 함수

    R Programming
    %%R
    
    sqldf(" SELECT SINH(1) sinh  ")

     

    Results
          sinh
    1 1.175201

     

     

     


    6. Python pandasql Package

     

    sinh() 함수

    Python Programming
    ps.sqldf(" SELECT sinh(1) sinh  ")

     

     

     


    7. R data.table Package

     

    sinh() 함수

    R Programming
    %%R
    
    DT          <- data.table(emp)
    dept_DT     <- data.table(dept)
    
    DT[, sinh := sinh(deptno/10)][1:10, ]

     

    Results
        empno  ename       job  mgr   hiredate  sal comm deptno      sinh
     1:  7369  SMITH     CLERK 7902 1980-12-17  800   NA     20  3.626860
     2:  7499  ALLEN  SALESMAN 7698 1981-02-20 1600  300     30 10.017875
     3:  7521   WARD  SALESMAN 7698 1981-02-22 1250  500     30 10.017875
     4:  7566  JONES   MANAGER 7839 1981-04-02 2975   NA     20  3.626860
     5:  7654 MARTIN  SALESMAN 7698 1981-09-28 1250 1400     30 10.017875
     6:  7698  BLAKE   MANAGER 7839 1981-03-01 2850   NA     30 10.017875
     7:  7782  CLARK   MANAGER 7839 1981-01-09 2450   NA     10  1.175201
     8:  7788  SCOTT   ANALYST 7566 1982-12-09 3000   NA     20  3.626860
     9:  7839   KING PRESIDENT   NA 1981-11-17 5000   NA     10  1.175201
    10:  7844 TURNER  SALESMAN 7698 1981-09-08 1500    0     30 10.017875

     


    8. Python Duckdb의 SQL

     

    Python Programming
    %%sql
      SELECT ((exp((0.5 * 2)) - 1) / (exp(0.5) * 2)) as SINH_func1,
             ((exp((1   * 2)) - 1) / (exp(1  ) * 2)) as SINH_func2

     

    Python Programming
    duckdb.sql(" SELECT ((exp((0.5 * 2)) - 1) / (exp(0.5) * 2)) as SINH_func1,                     \
                        ((exp((1   * 2)) - 1) / (exp(1  ) * 2)) as SINH_func2 ").df()

     

    Results
       SINH_func1  SINH_func2
    0    0.521095    1.175201

     


    ( https://unsplash.com/photos/hecib2an4T4 )

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

    [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 예제로 만나는 테이블 데이터 처리 방법 리스트 링크 링크
    반응형

    댓글