I have been working in a problem in python where I have a matrix of 3 columns and more than a million rows. The first column represents origin country, the second destination country, and the third the date. For example:
US AU 02/03/2020
US CN 03/04/2020
US MX 03/04/2020
AU US 02/03/2020
AU AU 02/03/2020
AU CN 03/04/2020
AU MX 03/04/2020
AU US 02/03/2020
US AU 02/03/2020
US CN 03/04/2020
US MX 03/04/2020
AU US 02/03/2020
And I want to count all the flights between two countries in a given day. For example, all flights from US to AU on 02/03/2020. I have done it with 3 for's and some if's, but it has been running for more than a week, and it hasn't finished. I wanted to know if anyone has a suggestion on how could I handle this problem in a more efficient way.
Thanks
sum(flight['from'] == 'US' and flight['to'] == 'AU' and flight['date'] == '02/03/2020' for flight in list_of_flights)