回答編集履歴

3

d

2018/12/21 18:50

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -44,15 +44,9 @@
44
44
 
45
45
 
46
46
 
47
- data = pd.read_csv('data.txt', names=['Index', 'A', 'B', 'C'])
47
+ data = pd.read_csv('data.txt', names=['Index', 'X', 'Y', 'Z'])
48
-
49
-
50
-
51
- # 51n % 51 == 0, 51n + 1 % 51 == 1
52
48
 
53
49
  indices = (data.Index % 51 != 0) & (data.Index % 51 != 1)
54
-
55
-
56
50
 
57
51
  extract = data[indices]
58
52
 

2

d

2018/12/21 18:50

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -34,6 +34,8 @@
34
34
 
35
35
  N行4列のCSVという前提です。
36
36
 
37
+ 51n, 51n+1 行以外を抜き出す方法
38
+
37
39
 
38
40
 
39
41
  ```python
@@ -48,7 +50,7 @@
48
50
 
49
51
  # 51n % 51 == 0, 51n + 1 % 51 == 1
50
52
 
51
- indices = (data.Index % 51 == 0) | (data.Index % 51 == 1)
53
+ indices = (data.Index % 51 != 0) & (data.Index % 51 != 1)
52
54
 
53
55
 
54
56
 

1

ss

2018/12/21 18:45

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -25,3 +25,35 @@
25
25
  print(extract)
26
26
 
27
27
  ```
28
+
29
+
30
+
31
+ ## pandas の場合
32
+
33
+
34
+
35
+ N行4列のCSVという前提です。
36
+
37
+
38
+
39
+ ```python
40
+
41
+ import pandas as pd
42
+
43
+
44
+
45
+ data = pd.read_csv('data.txt', names=['Index', 'A', 'B', 'C'])
46
+
47
+
48
+
49
+ # 51n % 51 == 0, 51n + 1 % 51 == 1
50
+
51
+ indices = (data.Index % 51 == 0) | (data.Index % 51 == 1)
52
+
53
+
54
+
55
+ extract = data[indices]
56
+
57
+ print(extract)
58
+
59
+ ```