著者の悲壮感というか、漂う諦め感みたいなのが好きかも。
「親離れ、子離れはあるけど、夫婦離れという言葉はないよな」ということ。ざらっとした感じが残った。
面白かった。
ポジティブかな
好きかも
このドープさは、かなり好き。江國香織が透明度高いのに対してスモーキーに感じる。
勢いとスピード
「勤労感謝の日」のほうが好みかな。
「女の過程」と「夏旅」はよかった。特に夏旅は惹きこまれた。
letter from home で泣いた
とても好き
著者の悲壮感というか、漂う諦め感みたいなのが好きかも。
「親離れ、子離れはあるけど、夫婦離れという言葉はないよな」ということ。ざらっとした感じが残った。
面白かった。
ポジティブかな
好きかも
このドープさは、かなり好き。江國香織が透明度高いのに対してスモーキーに感じる。
勢いとスピード
「勤労感謝の日」のほうが好みかな。
「女の過程」と「夏旅」はよかった。特に夏旅は惹きこまれた。
letter from home で泣いた
とても好き
R逆引きハンドブックのMatrixの章をPandasで。
作者の書いた本はオススメ
>>> pd.DataFrame([[1,2,3],[4,5,6]]) 0 1 2 0 1 2 3 1 4 5 6
>>> x = pd.DataFrame([[1,2,3],[4,5,6]]) >>> pd.DataFrame([[1,2,3],[4,5,6]]) 0 1 2 0 1 2 3 1 4 5 6 >>> x = pd.DataFrame([[1,2,3],[4,5,6]]) >>> x 0 1 2 0 1 2 3 1 4 5 6 >>> x.index = list("ab") >>> x.columns = list("cde") >>> x c d e a 1 2 3 b 4 5 6
>>> x = pd.DataFrame([[1,2,3],[4,5,6]], index=list("ab"), columns=list("cde")) >>> x c d e a 1 2 3 b 4 5 6 >>> x["c"] a 1 b 4 Name: c, dtype: int64 >>> x.c a 1 b 4 Name: c, dtype: int64
Seriesが返ってくるのでメソッドもよべる
>>> x.c.mean() 2.5 >>> x.c.sum() 5
>>> x = pd.DataFrame([[1,2,3],[4,5,6]], index=list("ab"), columns=list("cde")) >>> y = pd.Series([7,8,9], index=list("cde")) >>> x.append(y, ignore_index=True) c d e 0 1 2 3 1 4 5 6 2 7 8 9
rbind
::: python >>> x 0 1 0 1 0 1 -2 3 >>> x.append(x) 0 1 0 1 0 1 -2 3 0 1 0 1 -2 3 >>> pd.concat([x, x], axis=0) 0 1 0 1 0 1 -2 3 0 1 0 1 -2 3
cbind
::: python >>> pd.concat([x, x], axis=1) 0 1 0 1 0 1 0 1 0 1 -2 3 -2 3
ggplotの組込みデータを使う。 wt>3のname,disp列を抽出
>>> from ggplot import mtcars >>> mtcars[mtcars.wt > 3][["name","disp"]] name disp 3 Hornet 4 Drive 258.0 4 Hornet Sportabout 360.0 5 Valiant 225.0 6 Duster 360 360.0 7 Merc 240D 146.7 8 Merc 230 140.8 9 Merc 280 167.6 10 Merc 280C 167.6 11 Merc 450SE 275.8 12 Merc 450SL 275.8 13 Merc 450SLC 275.8 14 Cadillac Fleetwood 472.0 15 Lincoln Continental 460.0 16 Chrysler Imperial 440.0 21 Dodge Challenger 318.0 22 AMC Javelin 304.0 23 Camaro Z28 350.0 24 Pontiac Firebird 400.0 28 Ford Pantera L 351.0 30 Maserati Bora 301.0
transform
>>> x = pd.DataFrame([(1,2),(3,4),(5,6),(7,8)]) >>> x 0 1 0 1 2 1 3 4 2 5 6 3 7 8 >>> x[2] = x[0]+2 >>> x 0 1 2 0 1 2 3 1 3 4 5 2 5 6 7 3 7 8 9
R expand.grid() function in Python
::: python >>> x 0 1 2 0 1 2 3 1 4 5 6 2 7 8 9 >>> x.sum(axis=0) 0 12 1 15 2 18 dtype: int64 >>> x.sum(axis=1) 0 6 1 15 2 24 dtype: int64
>>> x = pd.DataFrame([(1,2),(3,4),(5,6),(7,8)]) >>> x.apply(sum) 0 16 1 20 dtype: int64
>>> x = pd.DataFrame([(1,2),(3,np.nan),(np.nan,6),(7,8)]) >>> x 0 1 0 1 2 1 3 NaN 2 NaN 6 3 7 8 >>> x.dropna() 0 1 0 1 2 3 7 8
multiindex便利
>>> x = pd.DataFrame([(1,"Y"),(3,"N"),(6,"N"),(7,"Y")]) >>> x 0 1 0 1 Y 1 3 N 2 6 N 3 7 Y >>> y = x.groupby(1) >>> y.head() 0 1 1 N 1 3 N 2 6 N Y 0 1 Y 3 7 Y >>> y.mean() 0 1 N 4.5 Y 4.0
>>> x = pd.DataFrame([(1,0,1),(1,1,2),(1,2,0),(2,0,1),(2,1,1),(2,2,3),(3,0,0),(3,1,1),(3,2,2)], columns=["subject","time","conc"]) >>> x subject time conc 0 1 0 1 1 1 1 2 2 1 2 0 3 2 0 1 4 2 1 1 5 2 2 3 6 3 0 0 7 3 1 1 8 3 2 2 >>> x.pivot(index="time", columns="subject") conc subject 1 2 3 time 0 1 1 0 1 2 1 1 2 0 3 2
groupby
>>> x = pd.DataFrame([(1,0,1),(1,1,2),(1,2,0),(2,0,1),(2,1,1),(2,2,3),(3,0,0),(3,1,1),(3,2,2)], columns=["subject","time","conc"]) >>> x subject time conc 0 1 0 1 1 1 1 2 2 1 2 0 3 2 0 1 4 2 1 1 5 2 2 3 6 3 0 0 7 3 1 1 8 3 2 2 >>> x.sort("time") subject time conc 0 1 0 1 3 2 0 1 6 3 0 0 1 1 1 2 4 2 1 1 7 3 1 1 2 1 2 0 5 2 2 3 8 3 2 2
R逆引きハンドブックのMatrixの章をPandasで。
Pandasの場合MatrixないからDataFrameだけど。
行列ではなくデータフレーム
>>> x = pd.DataFrame([[1,0],[-2,3]]) >>> y = pd.DataFrame([[-1,1],[4,2]]) >>> x.dot(y) 0 1 0 -1 1 1 14 4 >>> x * y 0 1 0 -1 0 1 -8 6
x %o% y はわからない
逆行列もnumpyに頼る感じ
applyでaxisで行か列かを選択する。applyはよく使う
>>> x 0 1 0 1 0 1 -2 3 >>> x.apply(sum, axis=0) #colsum 0 -1 1 3 dtype: int64 >>> x.apply(sum, axis=1) #rowsum 0 1 1 1 dtype: int64
numpyのarrayに
>>> x 0 1 0 1 0 1 -2 3 >>> x.as_matrix() array([[ 1, 0], [-2, 3]], dtype=int64)
DataFrameなので
>>> x 0 1 0 1 0 1 -2 3 >>> x.index Int64Index([0, 1], dtype=int64) >>> x.columns Int64Index([0, 1], dtype=int64) >>> x.index = list("ab") >>> x.columns = list("cd") >>> x c d a 1 0 b -2 3
>>> x.shape (2, 2)
>>> x 0 1 2 3 0 1 2 3 4 1 5 6 7 8 2 9 10 11 12 3 13 14 15 16 >>> x.iloc[[2],[3]] 3 2 12 >>> x.iloc[1:4,[3]] 3 1 8 2 12 3 16
rbind
concatで行か列を指定する。これもよく使う
>>> x 0 1 0 1 0 1 -2 3 >>> x.append(x) 0 1 0 1 0 1 -2 3 0 1 0 1 -2 3 >>> pd.concat([x, x], axis=0) 0 1 0 1 0 1 -2 3 0 1 0 1 -2 3
cbind
>>> pd.concat([x, x], axis=1) 0 1 0 1 0 1 0 1 0 1 -2 3 -2 3
>>> pd.DataFrame(np.diag(range(4))) 0 1 2 3 0 0 0 0 0 1 0 1 0 0 2 0 0 2 0 3 0 0 0 3
>>> x 0 1 2 0 1 2 3 1 4 5 6 2 7 8 9 >>> pd.DataFrame(np.triu(x.as_matrix())) 0 1 2 0 1 2 3 1 0 5 6 2 0 0 9 >>> pd.DataFrame(np.tril(x.as_matrix())) 0 1 2 0 1 0 0 1 4 5 0 2 7 8 9
>>> x 0 1 2 0 1 2 3 1 4 5 6 2 7 8 9 >>> x.T 0 1 2 0 1 4 7 1 2 5 8 2 3 6 9
>>> x 0 1 2 0 1 2 3 1 4 5 6 2 7 8 9 >>> x.sum(axis=0) 0 12 1 15 2 18 dtype: int64 >>> x.sum(axis=1) 0 6 1 15 2 24 dtype: int64 >>> x.sum(axis=0).sum() 45
固有値分解
>>> x 0 1 0 4 1 1 1 4 >>> pd.DataFrame(np.linalg.eig(x.as_matrix())[1]) 0 1 0 0.707107 -0.707107 1 0.707107 0.707107
特異値分解は知らん
pandas本はpandasの話がメインなので逆引きがないのが辛いかなと思う。pandasに慣れると手放せないけど☆
というわけで、R言語逆引きハンドブックのベクトルの章をPandasでやってみた。
n = pd.Series(range(1,10)) n.apply(lambda r: "ID " + str(r))
f = pd.Series(["y","n","y","n","n"]) pd.factorize(f) (array([0, 1, 0, 1, 1]), array(['y', 'n'], dtype=object))
Why does pandas (python library) has no factor like variable?に書かれている
as.logicalに対応するものはない?
pd.Series([True, False, True, True])
>>> r = pd.Series(range(11)) >>> l = r[r > 5] >>> l.sum() 5 >>> l.any() True
which?
>>> l[l == True].index Int64Index([6, 7, 8, 9, 10], dtype=int64)
>>> pd.Series([]) Series([], dtype: float64)
length(x) <- 10
みたいにサイズを増やすことはできない?
減らすのは
>>> a = pd.Series(range(10)) >>> a[:5] 0 0 1 1 2 2 3 3 4 4 dtype: int64
>>> a = pd.Series(range(5), index=list("abcde")) >>> a a 0 b 1 c 2 d 3 e 4 dtype: int64 >>> a["c"] 2
>>> a = pd.Series(range(5), index=list("abcde")) >>> a[list("ace")] a 0 c 2 e 4 dtype: int64 >>> a[[0,2,4]] a 0 c 2 e 4 dtype: int64 >>> a[(a<1)|(a>3)] a 0 e 4 dtype: int64
indexを使う
>>> a = pd.Series(range(5)) >>> a[(a<1)|(a>3)].index Int64Index([0, 4], dtype=int64)
>>> import numpy as np >>> a = pd.Series(range(5)) >>> a.reindex(np.random.permutation(a.index)) 2 2 0 0 3 3 1 1 4 4 dtype: int64 >>> b = a.reindex(np.random.permutation(a.index)) >>> b.sort() >>> b 0 0 1 1 2 2 3 3 4 4 dtype: int64
>>> a = pd.Series(range(5)) >>> a 0 0 1 1 2 2 3 3 4 4 dtype: int64 >>> a[(a<1)|(a>3)] = 10 >>> a 0 10 1 1 2 2 3 3 4 10 dtype: int64
>>> a = pd.Series(range(5)) >>> a.append(pd.Series([0,0,0,0])) 0 0 1 1 2 2 3 3 4 4 0 0 1 0 2 0 3 0 dtype: int64
>>> a = pd.Series([1,2,3,4,5,4,6,3,2]) >>> a.duplicated() 0 False 1 False 2 False 3 False 4 False 5 True 6 False 7 True 8 True dtype: bool >>> a[a.duplicated()] 5 4 7 3 8 2 dtype: int64
>>> a.drop_duplicates() 0 1 1 2 2 3 3 4 4 5 6 6 dtype: int64
R逆引きハンドブックは手元に置いておくと重宝する☆
24122013 chemoinformatics
24122013 chemoinformatics
という、メディシナルケミストリーにとって非ロマンチックな指標を思いついでウキウキしてみたが、それって結局1-fsp3じゃないかと気付いてげんなりしたのであった
透明かつせつない
決壊のレビューにこっちも面白いと書いてあったので読んでみた。面白いけど、決壊は分人主義だからなぁ。こっちはミステリー要素が強いのかな?残りの巻を読むのが楽しみ
不思議な感覚
陰影のコントラストが大切
退廃的な感じが好き
三浦しをんも書いていたので読んだ
よく分からない不条理さというか
情景がありありと浮かぶ。これは読んで良かった。
軽く読めた
挫折した
19122013 sake
一白水成は綺麗な味わい。

奈良萬のおりがらみ。

新政の限定のやつ、東京駅のはせがわ酒店で購入。

庭のうぐいすの冬濁りはシュワシュワ感が強かった。

17122013 work
(小指のミスで下書き消えたので投げやり)
PostgreSQLで使う場合はPsycopgをインストールして環境変数CHEMBL_URIを変える
CHEMBL_URI=postgresql+psycopg2://localhost/chembl_17
こんだけです。
尚、来年の1/18にChEMBLのハンズオンとかRedmineの事例紹介をやりますので、細かいこと聞きたいとか、dancyuで絶賛された地ビール飲みたいとかいうヒトは参加されるといいと思います。
というより、早めに人数が集まらないと懇親会の予約が取りにくいので困ります。bg7860とかとっとと登録してください。
あと、SureChemblっていうパテントに特化した構造データベースも立ち上がるみたいなので情報交換出来るといいですね。
また、時間があれば「創薬に役立つ統合TVベストn」とかやれればと思います。
これはかなり好き。デジャブったからかな。
江國香織は安定の透明感というかカタルシス
こういう風にお酒を飲みたい
村上春樹もよかった
陰翳礼讃
大衆受けのする感じかな。ちょっと浅い。
平野啓一郎の力強さは読み応えがある。
白痴まで読んでストップ。あわない。