numpy - ndarray - how to remove rows based on another array

前端 未结 2 2085
时光说笑
时光说笑 2021-01-21 07:03

I want to remove rows from a ndarray based on another array. for example:

k = [1,3,99]

n = [
  [1,\'a\']
  [2,\'b\']
  [3,\'c\']
  [4,\'c\']
  [.....]
  [99, \'         


        
2条回答
  •  不要未来只要你来
    2021-01-21 07:53

    If your data structure is list, please find simple solution as below, however you can convert into list by list() method.

    def check(list):
     k=[1,3,99]
     if(list[0] not in k): 
      return list
    
    final_list = map(check,n)
    final_list = final_list.remove(None)
    print final_list
    

提交回复
热议问题