Skip to content

Instantly share code, notes, and snippets.

@yoki
yoki / 00_polars_basic.py
Last active August 24, 2024 17:59
Polars tutorial
import polars as pl
from polars import col
# Creating DataFrames
df = pl.DataFrame({
'A': [1, 2, 3, 4],
'B': ['a', 'b', 'c', 'd'],
'C': [1.1, 2.2, 3.3, 4.4]
})
@yoki
yoki / regression.py
Last active November 8, 2022 03:55
Python Statistics
import pandas as pd
from sklearn import datasets
import statsmodels.api as sm
from stargazer.stargazer import Stargazer
from IPython.core.display import HTML
diabetes = datasets.load_diabetes()
df = pd.DataFrame(diabetes.data)
df.columns = ['Age', 'Sex', 'BMI', 'ABP', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6']
df['target'] = diabetes.target
@yoki
yoki / main.py
Created December 26, 2020 01:50
Python Errors and Exceptions
try:
func()
except IOError as exc:
print(exc)
raise exc
# Variable, type and functions https://github.com/PacktPublishing/Julia-1.0-Programming-Cookbook/tree/master/Chapter05
@yoki
yoki / update-insert.sql
Last active August 23, 2020 14:18
update-insert.sql
UPDATE courses_question q
SET video = ''
FROM courses_questioncategory qc
WHERE qc.category = 'recordingVoiceImageOnly'
AND q.question_category_id = qc.id
@yoki
yoki / bash_profile.sh
Last active May 25, 2020 14:24
bash_profile
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export CLICOLOR=1
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
export HISTFILESIZE=100000
export HISTSIZE=100000
export LSCOLORS=GxFxCxDxBxegedabagaced
@yoki
yoki / io.js
Last active December 26, 2019 23:30
JS io
// Easiest
// Mydata.json.js defines a variable
<script src="mydata.json.js"></script>
//? work
fetch("test.json")
.then(response => response.json())
.then(json => console.log(json));
# 1_matplotlib
# 2_seaborn
@yoki
yoki / 00_pandas.py
Last active January 26, 2023 07:21
Pandas tutorial
# 10_generation
# 11_filter
# 12_setting_value
# 13_io
# 15_groupby
# 16_merge
# 17_pivot_reshape
# 18_misc
# 19_type
# 21_category
@yoki
yoki / 0_list_operation_iteration.py
Last active February 8, 2023 21:24
List operation/Control sequence/Repeat
# 1_loop.py
# 2_list_operation.py