分類: Python
Python 相關的程式碼、套件
Heroku deployment
登入 heroku
$ heroku login heroku: Press any key to open up the browser to login or q to exit:
檢視目前已存在的 apps
$ heroku apps === xxxx@gmail.com Apps app1
新增一個名為 mysite 的 app
$ heroku create mysite Creating ⬢ mysite... ! ! Name mysite is already taken
(顯示此名稱已被使用)
(以下為假設名稱app2沒有被使用的情況)
$ heroku create app2 Creating ⬢ app2... done https://app2.herokuapp.com/ | https://git.heroku.com/app2.git
Python Idioms
使用 enumerate 進行 iteration
好的程式碼:
fruits = ['orange', 'grape', 'pitaya', 'blueberry']
for index, fruit in enumerate(fruits):
print(index, ':', fruit)
不好的程式碼:
fruits = ['orange', 'grape', 'pitaya', 'blueberry']
index = 0
for fruit in fruits:
print(index, ':', fruit)
index += 1
Seaborn Plot
Today’s note on GitHub:
https://github.com/jumpingchu/Notes/blob/master/Seaborn%20Practice.ipynb
.str.endswith() / .str.split() / Counter()
Series.str.endswith(pat, na=nan)
Test if the end of each string element matches a pattern.
>>> s = pd.Series(['bat', 'bear', 'caT', np.nan]) >>> s.str.endswith('t') 0 True 1 False 2 False 3 NaN
>>> s.str.endswith('t', na=False) 0 True 1 False 2 False 3 False