Skip to content

Instantly share code, notes, and snippets.

View joonro's full-sized avatar

Joon Ro joonro

View GitHub Profile
joonro /
Last active June 8, 2023 14:23
[General Multiprocessing of pandas.DataFrame with multiple arguments] Using multiple arguments, spliting pandas.DataFrame #python #multiprocessing #pandas
import numpy as np
import pandas as pd
def cal_d(partial_panel, nvid_jt, movchr, r_all):
for r, row in enumerate(partial_panel.itertuples()):
showdate = pd.Timestamp(str(row.showdate))
nvid = row.nvid
reldate =[nvid, 'reldate']
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 / Qualtrics.SurveyEngine.getEmbeddedData.js
Last active March 18, 2022 18:06
[Qualtrics/Store and retrieve embedded data] This example is with time calculation since the survey start #qualtrics #JavaScript
/*Place your JavaScript here to run when the page loads*/
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var current_time_in_minutes = hours * 60 + minutes
joonro / price_elasticity_XP.sql
Created September 24, 2021 17:15
[Uber Freight: Price Elasticity XP] #sql #querybuilder
- 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
# test partial
from functools import partial
def frozen_func():
return 2
def target_func(x, frozen_func):
joonro / matplotlib bar chart
Last active June 9, 2021 16:08
[pandas/matplotlib bar chart] #python #plot #matplotlib #pandas
# 2021-06-09 This is older way
import matplotlib.pyplot as plt
def plot_bar_chart_interaction(
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):