[Personal Cheat Sheet]

홍성환·2021년 9월 14일
1

Pandas


from IPython.core.display import display, HTML

## 전체 구간을 넓게

display(HTML("<style>.container { width:100% !important; }</style>"))

## 각 컬럼 width 최대로

pd.set_option('display.max_colwidth', -1)

## rows 500

pd.set_option('display.max_rows', 500)

## columns

pd.set_option('display.max_columns', 500)

pd.set_option('display.width', 1000)

s3

  • s3 list 가져오기

    s3.list_objects(Bucket=bucket_name, Prefix=prefix)['Contents']
  • s3 cp s3 to s3

import boto3
s3 = boto3.resource('s3')
copy_source = {
    'Bucket': 'mybucket',
    'Key': 'mykey'
 }
s3.meta.client.copy(copy_source, 'otherbucket', 'otherkey')
  • s3 cp s3 to s3
import os
import boto3

#initiate s3 resource
s3 = boto3.resource('s3')

# select bucket
my_bucket = s3.Bucket('my_bucket_name')

# download file into current directory
for s3_object in my_bucket.objects.all():
    # Need to split s3_object.key into path and file name, else it will give error file not found.
    path, filename = os.path.split(s3_object.key)
    my_bucket.download_file(s3_object.key, filename)

EC2

security group

git

  1. ssh-keygen -t ed25519 -C "your_email@example.com"
  2. cat id_ed25519.pub
  3. git sshkey에 붙여넣기
  4. ssh config
 Host github.com
  IdentityFile ~/.ssh/id_ed25519
  User git
  1. chmod 400 모든 파일

pyenv

pip install ipykernel
pyenv activate fff
python -m ipykernel install --user --name=ff

profile
Machine Learning Engineer: recsys, mlops

0개의 댓글