回答編集履歴

3

Update

2022/04/19 00:06

投稿

melian
melian

スコア21149

test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  #
14
14
  lst = [5, 7, 8]
15
- dfx = df[~df[['Col_0']].isin(lst).values]
15
+ dfx = df[~df['Col_0'].isin(lst).values]
16
16
  print(dfx)
17
17
 
18
18
  #

2

Update

2022/04/19 00:00

投稿

melian
melian

スコア21149

test CHANGED
@@ -12,10 +12,11 @@
12
12
 
13
13
  #
14
14
  lst = [5, 7, 8]
15
- dfx = df[~df.isin(lst).any(axis=1)]
15
+ dfx = df[~df[['Col_0']].isin(lst).values]
16
16
  print(dfx)
17
17
 
18
18
  #
19
19
  Col_0 Col_1 Col_2 Col_3
20
20
  Row_0 0 1 2 3
21
+ Row_1 4 5 6 7
21
22
  ```

1

Update

2022/04/18 23:48

投稿

melian
melian

スコア21149

test CHANGED
@@ -3,12 +3,12 @@
3
3
  import io
4
4
 
5
5
  csv_data = '''
6
- Col_0,Col_1,Col_2,Col_3
6
+ ,Col_0,Col_1,Col_2,Col_3
7
- 0,1,2,3
7
+ Row_0,0,1,2,3
8
- 4,5,6,7
8
+ Row_1,4,5,6,7
9
- 8,9,10,11
9
+ Row_2,8,9,10,11
10
10
  '''
11
- df = pd.read_csv(io.StringIO(csv_data))
11
+ df = pd.read_csv(io.StringIO(csv_data), index_col=0)
12
12
 
13
13
  #
14
14
  lst = [5, 7, 8]
@@ -16,6 +16,6 @@
16
16
  print(dfx)
17
17
 
18
18
  #
19
- Col_0 Col_1 Col_2 Col_3
19
+ Col_0 Col_1 Col_2 Col_3
20
- 0 0 1 2 3
20
+ Row_0 0 1 2 3
21
21
  ```