Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import requests | |
import numpy as np | |
from io import StringIO | |
import time | |
import matplotlib.pyplot as plt | |
import html5lib | |
from datetime import datetime, timedelta | |
import calendar | |
import datetime as dt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM | |
( | |
上市公司財務比率 (FROM 損益表) | |
UNION | |
上櫃公司財務比率 (FROM 損益表) | |
) A | |
JOIN | |
( | |
上市公司財務比率 (FROM 資產負債表 / 現金流量表) | |
UNION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_key(x): | |
sku = x[0] | |
r_id = x[1] | |
for ele in sku: | |
ele['receipt_id'] = r_id | |
return sku | |
df['sku'] = df[['sku', 'receipt_id']].apply(add_key, axis=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import numpy as np | |
import requests | |
import pandas as pd | |
# prepare | |
url = 'https://raw.githubusercontent.com/hermitdave/FrequencyWords/master/content/2016/en/en_50k.txt' | |
r = requests.get(url) | |
d = r.text.split('\n')[:-1] | |
word = [t[0] if len(t)==2 else None for t in [i.split(' ') for i in d]] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def func(xlist): | |
return 2*(xlist[0]-2.3)**2+3*(xlist[0]-4.1)*(xlist[1]-6.5)+5*(xlist[1]-8.0)**2 | |
# functions | |
def partial_derivative(f, x_list, odr, epsilon = 1e-6, **kargs): | |
h_list = x_list.copy() | |
h_list[odr] = x_list[odr] + epsilon | |
fx = f(x_list, **kargs) | |
fh = f(h_list, **kargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test(xlist): | |
# xlist is the list of the variables we have, and in this particular instance we have two variables | |
return 2*xlist[0]**2+3*xlist[0]*xlist[1]+5*xlist[1]**2 | |
# functions | |
def partial_derivative(f, x_list, odr, epsilon = 1e-6, **kargs): | |
# 此為模擬偏微分會有少量誤差 | |
h_list = x_list.copy() | |
h_list[odr] = x_list[odr] + epsilon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def vocabulary(sample, start, end): | |
import string | |
p = sample.replace('-', ' ').translate(str.maketrans('', '', string.punctuation)).split() | |
p = [i.lower() for i in p] | |
p = [(i, df[df.word==i].index[0], list(df[df.word==i]['dic'])[0]) \ | |
if i in np.array(df.word) else (i, 99999, 'N') for i in p] | |
w = np.array(list(set(p)))[:,0] | |
r = np.array(list(set(p)))[:,1].astype(int) | |
d = np.array(list(set(p)))[:,2] | |
d = pd.DataFrame({'word':w |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder