> with np.printoptions(precision=3): > print( np.array([2.0]) / 3 )
pandas 숫자 출력 형식 변경
pandas에서 몇 가지 옵션을 바꾸는 방법을 정리해 보자. pandas의 옵션은 pd.options 를 사용한다.
pd.options.display
출력의 형태, 표기를 변경하는 것은 pd.options.display 아래에 있다. 여기서 사용할 수 있는 옵션은 describe_option() 으로 확인할 수 있다.
1 2 3 4 5 6 7
> pd.describe_option() compute.use_bottleneck : bool Use the bottleneck library to accelerate if it is installed, the default isTrue Valid values: False,True [default: True] [currently: True] ...
- row, column 출력 개수 조정
pd.options.display.max_rows : 표를 출력할 때 최대 행 수입니다.
pd.options.display.min_rows : 표를 출력할 때 최소 행 수입니다.
1 2 3 4 5
import pandas as pd > pd.options.display.max_rows 60 > pd.options.display.min_rows 10
pd.describe_option(OPTIONS) 를 사용하면 해당 옵션에 대한 설명을 출력해 준다.
1 2 3 4 5
> pd.describe_option("max_rows") display.max_rows : int If max_rows is exceeded, switch to truncate view. Depending on `large_repr`, objects are either centrally truncated or printed as a summary view. 'None' value means unlimited.
[project] name = "example_package_YOUR_USERNAME_HERE" version = "0.0.1" authors = [ { name="Example Author", email="author@example.com" }, ] description = "A small example package" readme = "README.md" requires-python = ">=3.7" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ]
This is a simple example package. You can use [Github-flavored Markdown](https://guides.github.com/features/mastering-markdown/) to write your content.
LICENSE 파일에 저작권을 명시한다.
1 2 3
Copyright (c) 2018 The Python Packaging Authority
Permission is hereby granted, free of charge, to any person obtaining a copy
배포 묶음 생성하기
배포를 위한 build 도구를 설치한다.
1
python3 -m pip install --upgrade build
packaging_tutorial 폴더 아래 pyproject.toml 파일이 있는 위치에서 배포를 위한 build 명령으로 소스를 패키징을 한다.
build 를 수행하면 별도의 venv 가상환경을 생성해서 의존성에 명시된 setuptools 등을 설치하고 빌드를 진행한다.
1 2 3 4 5 6 7
> python3 -m build * Creating venv isolated environment... * Installing packages in isolated environment... (setuptools>=61.0) ... ... removing build\bdist.win-amd64\wheel Successfully built example_package_YOUR_USERNAME_HERE-0.0.1.tar.gz and example_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
이 명령의 결과로 dist 폴더에 우리 프로젝트에 대한 배포용 패키징으로 소스 패키징 .gz 파일, built distribution 패키징 .whl 2개의 파일이 생성된다.
github, bitbucket 같은 클라우드 사이트에 Client 프로그램으로 SSH 접속을 위해서는 SSH 키 쌍 생성하고 클라우드 사이트에 등록해야 한다. 보통 github, bitbucket 등 같은 SSH 접근을 지원하는 사이트는 ssh-agent forwarding 방식을 사용한다.
클라이언트에서 bitbucket 에 SSH 접속이 가능한지 테스트한다. 단, 모든 SSH 연결은 최초 접속시 호스트 접속 여부를 묻는다. 아래 같이 bitbucket.org 접속시 접속 여부를 묻는 다이얼로그가 나온다.
1 2 3 4 5 6 7 8 9
$ ssh -T git@bitbucket.org The authenticity of host 'bitbucket.org (104.192.141.1)' can't be established. ED25519 key fingerprint is SHA256:ybgmFkzwOSotHTHLJgHO0QN8L0xErw6vd0VhFA9m3SM. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'bitbucket.org' (ED25519) to the list of known hosts. authenticated via ssh key. You can use git to connect to Bitbucket. Shell access is disabled
결과적으로 아래 같이 결과가 출력되면 성공한 상태다.
1 2 3
authenticated via ssh key.
You can use git to connect to Bitbucket. Shell access is disabled
이제 git 클라이언트에서 HTTPS, SSH 를 통해서 bitbucket 과 ssh 연결이 가능하다. git 클라이언트로 push, pull 등을 수행할 수 있다.
jupyterlab 의 확장 모듈을 다운받아 설치시 nodejs 실행 환경이 제공되야 한다.
jupyterlab 확장 build error
jupyterlab 의 확장 모듈을 다운받아 설치하다 보면 npm 과 연계한 프로그램이 많다. 아래 같은 nodejs 관련 에러를 발생한다.
1 2 3 4 5 6
daddy> jupyter lab build ... ... An error occurred. RuntimeError: npm dependencies failed to install See the log file for details: C:\Users\USERID\AppData\Local\Temp\jupyterlab-debug-4kr1lkn1.log
결론으로 현재 jupyterlab 을 실행하는 환경에서
nodejs 버전이 설치되어 있고
jupyterlab extensions가 활성화 되어 있다면
해당 로그 파일을 확인해 보면 대부분 nodejs 버전이 일치하지 않아서 아래 같은 로그를 기록하고 있어 보인다.
1 2
error readable-stream@4.3.0: The engine "node" is incompatible with this module. Expected version "^12.22.0 || ^14.17.0 || >=16.0.0". Got "14.15.0" error Found incompatible module.
GRANTALL PRIVILEGES ON DB이름.테이블이름 TO 아이디@호스트 IDENTIFIED BY'비밀번호'withgrant option;
-ALL PRIVILEGES : 모든 권한 추가 -SELECT, INSERT, UPDATE, DELETE, ... : 권한을 일부분을 추가 -withgrant option : GRANT를 사용할 수 있는 권한 추가 -Grant 로 주어지는 권한은 여기 [grant: privilege-levels](https://mariadb.com/kb/en/grant/#privilege-levels) 명령에서 찾을 수 있다.
아래는 userid 사용자가 특정 sampledb 에만 모든 권한을 부여하고 있다.
1 2
mysql>GRANTALL PRIVILEGES ON sampledb.*TO'USERID'@'localhost'; mysql> FLUSH PRIVILEGES;
다음 GRANT 명령에서 ALL PRIVILEGES ON *.* 는 모든 권한(ALL PRIVILEGES)을 모든 스카마의 모든 테이블 *.* 에 준다는 의미.