このコードを使用して、各クラスター内の各ユーザーのさまざまな品質指標の値を計算しました
>>> for name, group in df.groupby(["Cluster_id", "User"]):
... print 'group name:', name
... print 'group rows:'
... print group
... print 'counts of Quality values:'
... print group["Quality"].value_counts()
... raw_input()
...
しかし今、私は出力を次のように取得します
group rows:
tag user quality cluster
676 black fabric http://steve.nl/user_1002 usefulness-useful 1
708 blond wood http://steve.nl/user_1002 usefulness-useful 1
709 blond wood http://steve.nl/user_1002 problematic-misspelling 1
1410 eames? http://steve.nl/user_1002 usefulness-not_useful 1
1411 eames? http://steve.nl/user_1002 problematic-misperception 1
3649 rocking chair http://steve.nl/user_1002 usefulness-useful 1
3650 rocking chair http://steve.nl/user_1002 problematic-misperception 1
counts of Quality Values:
usefulness-useful 3
problematic-misperception 2
usefulness-not_useful 1
problematic-misspelling 1
私が今やりたいことは、チェック条件を持つことです。
if quality==usefulness-useful:
good = good + 1
else:
bad = bad + 1
私は出力を書いてみました:
counts of Quality Values:
usefulness-useful 3
problematic-misperception 2
usefulness-not_useful 1
problematic-misspelling 1
変数に入れ、変数を行ごとにトラバースしようとしましたが、機能しません。特定の行で計算を行う方法について、誰かが私に提案をしてもらえますか。