回答編集履歴

2

回答を修正

2017/08/20 12:50

投稿

magichan
magichan

スコア15898

test CHANGED
@@ -41,3 +41,37 @@
41
41
 
42
42
 
43
43
  でどうでしょうか。
44
+
45
+
46
+
47
+ ---
48
+
49
+
50
+
51
+ **回答の修正**
52
+
53
+
54
+
55
+ 最大値があるラベルを求めたい場合は、``Series.argmax()``を使用するとよいと思います
56
+
57
+
58
+
59
+
60
+
61
+ ```Python
62
+
63
+ import pandas as pd
64
+
65
+ df = pd.DataFrame([[1,4,7],[2,5,8],[3,6,9]],columns = list("abc"))
66
+
67
+
68
+
69
+ for index, row in df.iterrows():
70
+
71
+ df.ix[index, 'RES'] = row.argmax()
72
+
73
+ print(df)
74
+
75
+ ```
76
+
77
+

1

コードの修正

2017/08/20 12:50

投稿

magichan
magichan

スコア15898

test CHANGED
@@ -36,8 +36,6 @@
36
36
 
37
37
  df.ix[index, 'C'] = max(row)
38
38
 
39
- print(df)
40
-
41
39
  ```
42
40
 
43
41