Skip to content

Instantly share code, notes, and snippets.

roboreport roboreport

Block or report user

Report or block roboreport

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@roboreport
roboreport / postgres-cheatsheet.md
Created Sep 4, 2019 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
View convert_window.py
for s in range(1, 13):
train_sc_df['shift_{}'.format(s)] = train_sc_df['trade_price_idx_value'].shift(s)
test_sc_df['shift_{}'.format(s)] = test_sc_df['trade_price_idx_value'].shift(s)
train_sc_df.head(13)
View convert_pd.py
train_sc_df = pd.DataFrame(train_sc, columns=['trade_price_idx_value'], index=train.index)
test_sc_df = pd.DataFrame(test_sc, columns=['trade_price_idx_value'], index=test.index)
train_sc_df.head()
View scale_data.py
from sklearn.preprocessing import MinMaxScaler
sc = MinMaxScaler()
train_sc = sc.fit_transform(train)
test_sc = sc.transform(test)
train_sc
View splitdata.py
# 2017/1/1 까지의 데이터를 트레이닝셋.
# 그 이후 데이터를 테스트셋으로 한다.
split_date = pd.Timestamp('01-01-2017')
train = df.loc[:split_date, ['trade_price_idx_value']]
test = df.loc[split_date:, ['trade_price_idx_value']]
ax = train.plot()
test.plot(ax=ax)
View importfile.py
# 파일 업로드 기능 실행
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn])))
View house_index_prediction_1.py
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
# 파일 업로드 기능 실행
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
View crawl_news.php
<?php
echo "\nstock cron start".date("Ymd")."\n";
$start=1;
$display=20;
$total=20;
$newname = "news.txt";
$line = "";
for($start=1;$start <=$total; $start=$start+$display)
View plot result.py
%matplotlib inline
import matplotlib.pyplot as plt
Y_pred = lm.predict(X_test)
plt.scatter(Y_test, Y_pred)
plt.xlabel("Price Index: $Y_i$")
plt.ylabel("Predicted price Index: $\hat{Y}_i$")
plt.title("Prices vs Predicted price Index: $Y_i$ vs $\hat{Y}_i$")
View sort_coef.py
X_Cols = X_train.rename(columns= {'region_cd': '지역코드(시도)', 'year': '연도', 'month':'', 'building_type': '부동산타입',
'tradeprice_sido' : '매매가격지수(시도)', 'construction_realized_amount' : '건설기성액(백만원)', "cd": "cd(91일물)",
'spirit_deposit_rate': '정기예금금리', 'exchange_rate': '환율', 'composite_stock_price_index': '종합주가지수',
'economy_growth': '경제성장률','exchequer_bond_three' : '국고채3년','household_loan_all': '가계대출액(전국)',
'mortgage_all' : '주택대출액(전국)', 'numberofnosells':'미분양 가구수(시도)','unsalenum_c':'공사완료후 미분양(민간,시도)' })
print(X_train.columns)
coefs = pd.DataFrame(zip(X_Cols.columns,lm.coef_), columns = ['features', 'coefficients'])
You can’t perform that action at this time.