Skip to content

Instantly share code, notes, and snippets.

View joonro's full-sized avatar

Joon Ro joonro

View GitHub Profile
joonro /
Created November 28, 2022 21:21
[orgmode table frequently used formula] #orgmode #emacs
  • $ (e.g., $4) represents columns, @ (e.g., @2) represents rows.
  • $> means the last column.

Last row sum of all above:

joonro / price_elasticity_XP.sql
Created September 24, 2021 17:15
[Uber Freight: Price Elasticity XP] #sql #querybuilder
View price_elasticity_XP.sql
- 2021-09-24 Received this from He
with elasticity_xp as
, max_by(msg.elasticity_experiment.pre_xp_price, ts) as pre_xp_price
, max_by(msg.elasticity_experiment.post_xp_price, ts) as post_xp_price
, max_by(msg.elasticity_experiment.perturbation_factor, ts) as perturbation_factor
joonro / freeze a func with a function
Created June 23, 2021 15:45
[Freeze a function with a function argument with partial] I guess it should work, but I can freeze a function with function arguments as well. #python #multiprocessing
View freeze a func with a function
# test partial
from functools import partial
def frozen_func():
return 2
def target_func(x, frozen_func):
joonro /
Created May 22, 2021 23:12
[IPython.display] Import `display` function for jupyter notebooks #python
from IPython.display import display
joonro /
Last active March 27, 2020 22:42
[Python dealing with UTC timestamps] 2020-03-27 It seems this method is accurate because it explicitly specifies UTC time. #pyhton #time
import datetime
# get UTC timestamp in seconds
datetime_utc_origin = datetime.datetime(1970, 1, 1)
# now
utc_timestamp_now = (datetime.datetime.utcnow() - datetime_utc_origin).total_seconds()
joonro /
Created December 10, 2019 06:03
[Probability of randomly choose r correct answers out of n total questions] #python #teaching
import math
n = 33 # number of questions
r = 6 # number of correct answers
probs = []
for r in range(n):
joonro /
Created November 11, 2019 16:22
[pandas groupby date and time] #python
# specify time frequency of groupby
groupby_freq = 'W'
gr = df.groupby(
pd.Grouper(key='date', freq=groupby_freq)
joonro / matplotlib bar chart
Last active June 9, 2021 16:08
[pandas/matplotlib bar chart] #python #plot #matplotlib #pandas
View matplotlib bar chart
# 2021-06-09 This is older way
import matplotlib.pyplot as plt
def plot_bar_chart_interaction(
joonro / pandas Colored
Created July 25, 2019 05:02
[pandas DataFrame Correlation Matrix with Colored Entries] Remove lower-tri elements, make large numbers red #python #pandas #color #DataFrame
View pandas Colored
def color_large_value_red(val):
Takes a scalar and returns a string with
the css property `'color: red'` for absolute values > 0.5,
black otherwise.
float_val = float(val)
color = 'red' if (abs(float_val) > 0.4) and (float_val != 1) else 'black'