回答編集履歴

1

コード修正

2019/02/10 07:42

投稿

can110
can110

スコア38266

test CHANGED
@@ -4,13 +4,21 @@
4
4
 
5
5
  import pandas as pd
6
6
 
7
- df = pd.DataFrame({'c':[1,2]})
7
+ s = pd.Series([1,2])
8
8
 
9
9
 
10
10
 
11
11
  # ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
12
12
 
13
+ #if s < 3:
14
+
15
+ # print('abc')
16
+
17
+
18
+
19
+ # OK
20
+
13
- if df['c'] < 3:
21
+ if s.all() < 3:
14
22
 
15
23
  print('abc')
16
24
 
@@ -18,15 +26,7 @@
18
26
 
19
27
  # OK
20
28
 
21
- if df['c'].all() < 3:
22
-
23
- print('abc')
24
-
25
-
26
-
27
- # OK
28
-
29
- if df['c'].any() < 3:
29
+ if s.any() < 3:
30
30
 
31
31
  print('abc')
32
32