Skip to content

Instantly share code, notes, and snippets.

View Beomi's full-sized avatar

Junbum Lee Beomi

View GitHub Profile
@Beomi
Beomi / .vimrc
Last active August 7, 2023 02:08
기본적인 VIM용 세팅
set backspace=2
set autoindent
set smartindent
set expandtab
set et
set tabstop=4
set shiftwidth=4
set showmatch
set ignorecase
set incsearch
@Beomi
Beomi / reduce_mem_usage.py
Created September 4, 2019 11:36
Reduce Pandas Memory Usage #python #pandas
def reduce_mem_usage(df):
start_mem = df.memory_usage().sum() / 1024**2
print('Memory usage of dataframe is {:.2f} MB'.format(start_mem))
for col in df.columns:
col_type = df[col].dtype
if col_type != object:
c_min = df[col].min()
c_max = df[col].max()
if str(col_type)[:3] == 'int':
@Beomi
Beomi / Dockerfile
Last active August 30, 2019 10:23
Dockerfile for python(django) project
FROM python:3.7
ENV PYTHONUNBUFFERED 1
ENV PIPENV_VENV_IN_PROJECT 1
RUN mkdir /code
WORKDIR /code
RUN pip install -U pip && \
pip install pipenv
@Beomi
Beomi / docker-compose.yaml
Created August 30, 2019 10:03
docker compose file for template
version: "3"
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
@Beomi
Beomi / dask_n_sklearn.py
Created August 20, 2019 05:10
DASK + SKLearn
from sklearn.externals import joblib
with joblib.parallel_backend('dask'):
grid_search.fit(X, y)
@Beomi
Beomi / pandas_n_dask.py
Created August 20, 2019 05:09
Pandas 3종세트 + Dask
import pandas as pd
pd.set_option('display.max_columns', None) # or 1000
pd.set_option('display.max_rows', 100) # or 1000
pd.set_option('display.max_colwidth', -1) # or 199
import pandas_explode
pandas_explode.patch()
@Beomi
Beomi / cuda.py
Created August 20, 2019 05:09
Cuda visible
import os
os.environ["CUDA_VISIBLE_DEVICES"]="2"
os.environ['CUDA_VISIBLE_DEVICES']
@Beomi
Beomi / tweeter_follow_counter.py
Created August 13, 2019 08:51
Twitter Follow counter by Username
import requests
from bs4 import BeautifulSoup as bs
def _word_to_int(x):
if x.isdigit():
return int(x)
if 'K' in x:
return int(float(x[:-1]) * 1000)
def get_follow_counts(username):
@Beomi
Beomi / pandas_multicolum_index_plot.py
Last active August 9, 2019 17:50
Pandas Multi Column 그리기
def plot_multi(data, cols=None, spacing=.1, **kwargs):
from pandas import plotting
# Get default color style from pandas - can be changed to any other color list
if cols is None: cols = data.columns
if len(cols) == 0: return
# colors = getattr(getattr(plotting, '_style'), '_get_standard_colors')(num_colors=len(cols))
# colors = [rand_color.generate() for _ in range(len(cols))]
# colors = rand_color.generate(hue="blue", count=len(cols))
#! /bin/bash
#
# Copyright 2014 Lucy Park
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#