# 国数を数える num = len(series_countries_unique) # 上のリストに追加 num_countries.append(num) for name, num in zip(continent_list,num_countries): print(f'{name}: {num}') sum(num_countries) ## groupby() df_group = df.groupby('continent') from see import * see(df_group) ### continentの内訳(again) # Seriesを返す country_names = df_group['country'].unique() country_names N = len(country_names) for i in range(N): t0 = country_names[i] t1 = len(t0) print(country_names.index[i],':',t1)
def tell(name, default=not_equal): return lambda: see(name, default=default)
### Logitモデル 回帰式の設定 formula = 'inlf ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6' 推定の計算には`statsmodels`の`logit`関数を使う。使い方は`statsmodels`の`ols`と同じである。 res_logit = logit(formula, data=mroz).fit() 結果の表示 print(res_logit.summary()) `dir()`や`see()`を使うと,推定結果の属性やメソッドを確認できる。 see(res_logit) 例えば,`bse`は係数の標準誤差の属性である。 --- 不均一分散について考察する。誤差項の分散が均一か不均一かを考える上で,2つの方法を説明する。 1. 不均一分散頑健標準誤差を使う場合と使わない場合の標準誤差を比べる。 * 違いが小さければ,均一分散の可能性が高い。 * しかし,これは1つの目安である。 1. 検定を用いる * 考え方:不均一分散の仮定の下で最尤推定し,均一分散と比較する。 ---
def clusLoc2(): """ if a transform is already selected, don't create a locator move transform to the requested location """ sel = pm.selected(flatten = True) print sel # HOLDERS verts = [] edges = [] tfms = [] # Sort for s in sel: sortMe = s.__class__.__name__ if sortMe == "Joint" or sortMe == "Transform": tfms.append(s) if sortMe == "MeshVertex": verts.append(s) if sortMe == "MeshEdge": edges.append(s) # CONVERT EDGES TO VERTS if edges: edgeVerts = list(set(sum( [list(e.connectedVertices()) for e in edges], []) ) ) verts = verts + edgeVerts _logger.debug("verts = {}".format(verts)) _logger.debug("tfms = {}".format(tfms) ) import see print see(tfms) # CLUSTER clusDef, clustTfm = pm.cluster(verts) if not tfms: loc = pm.spaceLocator() tfms.append(loc) # LOOP THROUGH TFMS for tfm in tfms: parent = tfm.getParent() children = tfm.getChildren(type = "transform") if parent: tfm.setParent(world = True) _logger.debug("children = {}".format(children)) for child in children: child.setParent(world = True) pm.delete( pm.pointConstraint(clustTfm, tfm, mo = False)) for child in children: child.setParent(tfms) if parent: tfm.setParent(parent) # CLEAR THE CLUSTER pm.delete(clustTfm) _logger.debug("DONE")