A
A
Alexyz Canson2019-09-18 17:47:02
Python
Alexyz Canson, 2019-09-18 17:47:02

How to remove duplicates in a two-dimensional array by replacing?

The array list
[ ['0.00221980', '0.00000000'] , ['0.00222220', '16.05000000'], ['0.00222230', '60.78000000'], ['0.00222240', '0.00000000'] , ['2.5000'] , ['2.50 0.00000000'] , ['0.00222260', '25.87000000'], ['0.00222270', '67.41000000'], ['0.00222280', '18.61000000'], ['0.00228000', '1880.0'i]
should be removed from it ]
, ['0.00222280', '18.61000000'] ,['0.00228000', '1882.18000000'] ]
more
array ['0.00222280', '0.00000000'], ['0.00228000', '0.00000000'], ['0.00222264', '31.17000000']
there is a kind of replacement if with 0 it deletes
[ ['0.00222220', '16.05000000'], ['0.00222230', '60.78000000'], ['0.00222260', '25.87000000'], ['0.00222270', '67.4'000000] ]
and adds which is normal
[ ['0.00222220', '16.05000000'], ['0.00222230', '60.78000000'], ['0.00222260', '25.87000000'], ['0.00222270', '67.41000000'2], ['2.06000'2 , '31.17000000'] ] and
sorts in ascending order by 1 number
if there is already an incoming value, then leave which is included
in python.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
o5a, 2019-09-18
@jone21

Judging by the description, from both arrays it is necessary to remove all elements that have the same 1st value in the 2nd '0.00000000'. Then we can do this (a, b are our arrays):

# находим все значения с нулями
nn = [x[0] for x in a+b if x[1] == '0.00000000']
# фильтруем суммарный массив по этим значениям
d = [x for x in a+b if x[0] not in nn]
# в конце сортируем
d.sort()
print(d)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question