从值列表python过滤嵌套的有序字典

时间:2020-05-28 06:22:39

标签: python numpy filter ordereddictionary

我有一个命令字典,需要过滤与以下唯一ID匹配的所有行:

array([111, 335], dtype=int64)

看起来像:

OrderedDict([('UniqueID',
          masked_array(data=[111, 335],
                       mask=False,
                 fill_value=999999,
                      dtype=int64)),
         ('Ididloc',
          masked_array(data=[1234123, 1234679],
                       mask=False,
                 fill_value=999999,
                      dtype=int64)),
         ('personID',
          masked_array(data=['1','6'],
                       mask=False,
                 fill_value='?',
                      dtype=object)),
         ('Date',
          masked_array(data=['2008-03-07T00:00:00.000000',
                             '2009-07-22T00:00:00.000000'],
                       mask=False,
                 fill_value=numpy.datetime64('NaT'),
                      dtype='datetime64[us]')),

这是有序词典示例:

OrderedDict([('UniqueID',
          masked_array(data=[111, 112, 113, ..., 334, 335, 336],
                       mask=False,
                 fill_value=999999,
                      dtype=int64)),
         ('Ididloc',
          masked_array(data=[1234123, 1234124, 1234125, ..., 1234678, 1234679,
                             1234679],
                       mask=False,
                 fill_value=999999,
                      dtype=int64)),
         ('personID',
          masked_array(data=['1', '2', '1', ...,
                             '4', '6', '9'],
                       mask=False,
                 fill_value='?',
                      dtype=object)),
         ('Date',
          masked_array(data=['2008-03-07T00:00:00.000000',
                             '2009-05-18T00:00:00.000000',
                             '2009-10-29T00:00:00.000000', ...,
                             '2008-02-05T00:00:00.000000',
                             '2009-07-22T00:00:00.000000',
                             '2008-07-31T00:00:00.000000'],
                       mask=False,
                 fill_value=numpy.datetime64('NaT'),
                      dtype='datetime64[us]')),

------使用numpy python3 ------

0 个答案:

没有答案