how to select a list with the most occurances - python
I have a list of lists that contains a list I am looking for. This list of lists contains 11 integers before a string and after that string is the number of times that list in particular has occurred e.g ['1', '1', '0', '1', '0', '1', '0', '0', '0', '0', '1', 'down', 9]. The string changes from time to time and can either be "up" or "down" meaning that the same list can occur twice e.g ['1', '1', '0', '1', '0', '1', '0', '0', '0', '0', '1', 'down', 9], ['1', '1', '0', '1', '0', '1', '0', '0', '0', '0', '1', 'up', 13].
What I seek assistance in is how do I make it so that in the instance the is a repeated list like as mentioned above, select the list with the most occurrences which in this case would be ['1', '1', '0', '1', '0', '1', '0', '0', '0', '0', '1', 'up', 13] while at the same time identifying the string.
To put in a more practical standpoint:
#this is the list of lists
listA = [['0', '1', '1', '0', '0', '0', '0', '1', '1', '0', '1', 'down', 5], ['0', '0', '0', '0', '1', '0', '0', '1', '1', '0', '0', 'down', 7], ['1', '1', '0', '1', '0', '1', '1', '0', '0', '1', '1', 'down', 1], ['0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', 'down', 6], ['1', '1', '1', '0', '0', '0', '0', '0', '1', '1', '1', 'down', 3], ['1', '0', '1', '0', '0', '1', '1', '1', '0', '0', '0', 'down', 9], ['0', '1', '1', '0', '0', '0', '0', '1', '0', '1', '1', 'up', 4], ['0', '0', '0', '1', '1', '1', '1', '0', '1', '0', '0', 'down', 8], ['1', '0', '1', '1', '0', '1', '1', '0', '1', '0', '1', 'up', 5], ['0', '1', '0', '1', '0', '1', '1', '0', '1', '0', '1', 'down', 3], ['0', '1', '0', '1', '1', '0', '0', '1', '0', '1', '0', 'down', 5], ['1', '1', '0', '1', '0', '0', '1', '1', '1', '0', '1', 'up', 6], ['0', '0', '1', '1', '1', '0', '1', '0', '0', '1', '1', 'up', 10], ['1', '1', '1', '1', '1', '1', '0', '0', '1', '0', '1', 'up', 3], ['0', '1', '1', '1', '0', '0', '0', '1', '0', '1', '1', 'down', 3], ['1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '0', 'up', 6], ['0', '0', '1', '1', '1', '0', '0', '0', '1', '0', '1', 'down', 7], ['1', '1', '0', '0', '1', '0', '0', '1', '0', '1', '1', 'down', 3], ['0', '0', '0', '0', '1', '1', '0', '1', '1', '1', '0', 'up', 3], ['1', '1', '0', '1', '0', '1', '1', '0', '1', '1', '0', 'up', 10], ['0', '1', '0', '1', '1', '1', '1', '0', '1', '0', '0', 'up', 6], ['0', '0', '1', '1', '0', '0', '1', '1', '1', '0', '0', 'down', 2], ['1', '1', '1', '1', '0', '0', '0', '0', '0', '1', '1', 'up', 4], ['0', '0', '0', '1', '1', '0', '1', '1', '0', '0', '0', 'down', 6], ['1', '0', '0', '1', '1', '0', '1', '1', '1', '0', '1', 'up', 7], ['0', '1', '0', '0', '1', '0', '0', '0', '1', '0', '1', 'down', 13], ['0', '1', '0', '0', '1', '1', '0', '0', '0', '0', '0', 'up', 2], ['0', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', 'down', 5], ['0', '0', '0', '0', '1', '0', '0', '1', '0', '1', '1', 'down', 9], ['0', '1', '1', '1', '1', '1', '1', '0', '0', '0', '1', 'up', 4], ['1', '1', '1', '0', '0', '0', '0', '1', '0', '0', '0', 'up', 3], ['0', '0', '1', '0', '1', '0', '0', '0', '1', '1', '0', 'down', 7], ['1', '0', '1', '1', '0', '1', '1', '0', '1', '1', '0', 'up', 5], ['0', '1', '0', '0', '1', '1', '1', '0', '0', '1', '0', 'down', 10], ['0', '1', '1', '0', '0', '1', '0', '0', '0', '0', '1', 'down', 6], ['1', '1', '0', '1', '1', '0', '0', '0', '0', '1', '1', 'down', 3], ['1', '1', '0', '1', '1', '1', '0', '1', '0', '0', '0', 'up', 4], ['1', '0', '0', '1', '1', '0', '1', '0', '1', '0', '1', 'down', 6], ['1', '0', '1', '0', '0', '0', '0', '0', '0', '0', '1', 'down', 6], ['0', '1', '1', '1', '1', '1', '1', '0', '1', '1', '1', 'up', 6], ['1', '0', '1', '0', '0', '0', '1', '0', '1', '0', '1', 'down', 8], ['0', '1', '0', '1', '1', '0', '1', '0', '0', '0', '1', 'down', 5], ['1', '1', '1', '1', '1', '1', '0', '0', '0', '0', '1', 'up', 4], ['1', '0', '0', '1', '1', '1', '0', '0', '1', '0', '0', 'up', 2], ['0', '0', '1', '0', '0', '1', '1', '1', '1', '0', '0', 'down', 2], ['0', '0', '1', '1', '0', '0', '1', '1', '1', '1', '1', 'up', 4], ['1', '0', '0', '0', '0', '0', '0', '1', '0', '1', '0', 'down', 3], ['1', '0', '1', '1', '0', '1', '1', '1', '1', '1', '0', 'up', 10], ['0', '0', '0', '0', '0', '0', '1', '1', '1', '0', '1', 'up', 3], ['1', '1', '0', '1', '0', '1', '0', '0', '1', '0', '0', 'down', 7], ['1', '1', '0', '1', '0', '1', '1', '1', '1', '0', '1', 'up', 6], ['0', '1', '1', '0', '1', '1', '0', '1', '0', '1', '0', 'down', 2], ['1', '1', '1', '1', '1', '1', '0', '1', '1', '0', '0', 'down', 1], ['1', '0', '1', '1', '0', '0', '1', '1', '0', '0', '0', 'down', 6], ['1', '0', '1', '0', '0', '1', '0', '0', '1', '1', '1', 'up', 4], ['1', '1', '0', '0', '0', '0', '1', '0', '0', '1', '1', 'up', 3], ['0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', 'up', 5], ['0', '0', '1', '0', '0', '0', '0', '1', '1', '1', '1', 'up', 2], ['0', '1', '1', '0', '1', '0', '1', '0', '1', '0', '1', 'up', 7], ['1', '1', '1', '0', '1', '1', '0', '0', '1', '0', '0', 'down', 5], ['0', '0', '1', '1', '0', '1', '1', '1', '0', '0', '1', 'up', 7], ['0', '1', '1', '1', '0', '1', '0', '0', '0', '1', '1', 'up', 11], ['1', '0', '1', '0', '0', '1', '0', '0', '0', '0', '1', 'down', 3], ['0', '0', '0', '0', '1', '0', '0', '0', '1', '1', '1', 'down', 11], ['0', '0', '0', '0', '1', '1', '0', '0', '0', '1', '0', 'down', 11], ['1', '0', '1', '0', '1', '0', '1', '1', '1', '0', '1', 'up', 6], ['0', '0', '1', '1', '1', '0', '0', '0', '1', '1', '0', 'down', 5], ['1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '0', 'down', 5], ['1', '0', '1', '0', '0', '1', '0', '1', '0', '0', '0', 'down', 14], ['1', '1', '0', '1', '0', '1', '1', '0', '0', '1', '1', 'up', 8], ['0', '1', '0', '0', '1', '0', '0', '0', '0', '1', '0', 'down', 10], ['1', '1', '0', '1', '1', '1', '0', '0', '1', '1', '1', 'up', 12], ['1', '0', '1', '1', '0', '1', '1', '1', '0', '0', '1', 'up', 8], ['1', '0', '0', '1', '0', '1', '0', '0', '0', '1', '0', 'down', 8], ['0', '1', '1', '0', '0', '1', '1', '0', '1', '0', '1', 'up', 7], ['1', '0', '0', '1', '0', '1', '0', '0', '1', '1', '1', 'down', 5], ['1', '1', '1', '1', '0', '0', '0', '1', '1', '1', '0', 'up', 5], ['1', '1', '1', '0', '0', '0', '0', '1', '0', '1', '0', 'down', 6], ['1', '0', '0', '1', '0', '0', '1', '0', '1', '1', '1', 'down', 2], ['1', '1', '1', '0', '0', '1', '1', '1', '0', '1', '0', 'down', 2], ['0', '1', '0', '1', '1', '1', '0', '0', '1', '1', '1', 'down', 1], ['0', '1', '1', '1', '1', '0', '1', '1', '0', '0', '0', 'up', 4], ['1', '0', '0', '0', '0', '0', '1', '1', '1', '1', '0', 'up', 1], ['0', '1', '1', '1', '1', '0', '1', '0', '1', '0', '0', 'down', 3], ['1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'down', 7], ['1', '0', '0', '1', '1', '1', '0', '0', '1', '1', '0', 'up', 3], ['0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '0', 'up', 8], ['1', '0', '1', '1', '1', '1', '1', '1', '0', '1', '1', 'up', 7], ['0', '0', '0', '0', '1', '1', '1', '0', '1', '1', '1', 'down', 4], ['1', '1', '0', '1', '1', '0', '1', '0', '1', '1', '0', 'up', 4], ['1', '0', '1', '1', '0', '0', '1', '0', '1', '0', '1', 'down', 5], ['1', '1', '0', '1', '1', '1', '0', '0', '0', '0', '1', 'down', 5], ['1', '0', '1', '0', '0', '1', '0', '0', '1', '1', '0', 'down', 9], ['1', '1', '0', '1', '0', '0', '0', '1', '1', '0', '1', 'up', 5], ['1', '1', '0', '1', '1', '0', '0', '1', '0', '1', '1', 'up', 9], ['0', '1', '1', '0', '1', '1', '1', '1', '0', '0', '0', 'up', 2], ['1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'down', 6], ['0', '1', '0', '1', '1', '1', '0', '1', '0', '0', '1', 'up', 8], ['0', '0', '0', '1', '1', '1', '0', '0', '1', '1', '1', 'down', 2], ['0', '1', '1', '0', '0', '0', '1', '1', '1', '1', '1', 'down', 1], ['1', '0', '1', '0', '0', '1', '1', '1', '0', '0', '1', 'up', 8], ['1', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', 'down', 9], ['0', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', 'up', 9], ['0', '1', '1', '0', '1', '0', '1', '0', '0', '1', '0', 'down', 3], ['0', '0', '1', '0', '0', '1', '1', '0', '1', '1', '1', 'down', 3], ['0', '0', '0', '1', '1', '0', '1', '0', '1', '1', '0', 'up', 4], ['0', '1', '0', '1', '1', '0', '1', '0', '1', '1', '1', 'down', 1], ['0', '1', '1', '1', '0', '0', '0', '1', '1', '1', '0', 'down', 2], ['1', '0', '0', '1', '1', '1', '0', '1', '1', '0', '0', 'up', 4], ['0', '0', '1', '1', '1', '0', '0', '1', '1', '0', '1', 'up', 13], ['1', '1', '0', '1', '1', '1', '0', '1', '0', '0', '0', 'down', 6], ['1', '1', '1', '0', '1', '0', '0', '1', '1', '1', '0', 'up', 8], ['0', '0', '1', '0', '0', '0', '0', '1', '0', '0', '0', 'down', 8], ['0', '1', '1', '1', '0', '0', '0', '0', '1', '1', '0', 'down', 2], ['1', '1', '0', '0', '1', '1', '0', '1', '0', '0', '0', 'down', 7], ['0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', 'down', 7], ['1', '1', '1', '0', '1', '1', '1', '0', '1', '1', '1', 'up', 10], ['0', '1', '0', '1', '1', '0', '0', '1', '0', '1', '1', 'up', 8], ['1', '0', '0', '0', '1', '1', '1', '0', '0', '1', '0', 'up', 1], ['0', '0', '1', '1', '1', '1', '0', '1', '1', '1', '0', 'up', 7], ['1', '0', '0', '1', '0', '1', '1', '1', '1', '0', '0', 'up', 4], ['1', '0', '1', '1', '1', '0', '1', '1', '0', '0', '1', 'up', 7], ['1', '0', '1', '1', '1', '0', '0', '1', '0', '0', '1', 'up', 5], ['0', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', 'up', 4], ['0', '1', '1', '0', '1', '0', '0', '0', '0', '0', '1', 'down', 6], ['1', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', 'up', 8], ['1', '1', '1', '1', '0', '0', '0', '0', '1', '1', '0', 'up', 7], ['1', '1', '0', '1', '0', '0', '1', '1', '0', '0', '1', 'up', 5], ['0', '0', '0', '0', '1', '0', '0', '1', '0', '1', '0', 'down', 5], ['1', '1', '1', '0', '0', '1', '0', '1', '1', '1', '0', 'up', 8], ['1', '1', '0', '1', '0', '0', '1', '0', '0', '0', '0', 'down', 14], ['1', '1', '0', '0', '1', '1', '1', '0', '1', '0', '0', 'up', 2], ['1', '0', '1', '1', '1', '0', '1', '1', '0', '0', '1', 'down', 2], ['1', '1', '1', '1', '1', '1', '1', '1', '1', '0', '0', 'up', 5], ['1', '1', '0', '0', '1', '0', '1', '1', '1', '1', '0', 'up', 4], ['1', '1', '1', '0', '0', '1', '0', '1', '0', '0', '1', 'down', 4], ['1', '1', '1', '0', '0', '0', '1', '1', '1', '0', '1', 'down', 3], ['1', '1', '1', '1', '1', '0', '0', '0', '0', '0', '1', 'down', 1], ['0', '0', '1', '0', '1', '0', '1', '0', '0', '0', '1', 'up', 2], ['1', '0', '0', '1', '1', '0', '1', '1', '0', '0', '0', 'down', 8], ['0', '1', '1', '0', '0', '0', '0', '1', '1', '0', '0', 'up', 4], ['0', '1', '1', '0', '0', '1', '0', '0', '0', '0', '0', 'down', 7], ['0', '0', '0', '1', '1', '0', '0', '1', '1', '0', '1', 'up', 5], ['1', '1', '0', '0', '0', '0', '1', '1', '0', '1', '0', 'down', 7], ['0', '1', '1', '1', '0', '1', '0', '1', '1', '1', '1', 'up', 11], ['0', '1', '1', '0', '1', '1', '1', '1', '0', '0', '1', 'up', 9], ['0', '0', '1', '0', '1', '1', '0', '1', '1', '0', '0', 'down', 4], ['0', '1', '0', '1', '0', '0', '1', '0', '0', '1', '0', 'up', 5], ['0', '1', '0', '1', '0', '1', '1', '0', '1', '0', '0', 'down', 8], ['0', '0', '0', '0', '0', '1', '1', '0', '0', '1', '1', 'up', 3], ['0', '0', '0', '1', '0', '0', '1', '1', '1', '0', '0', 'up', 3], ['1', '0', '1', '1', '1', '0', '0', '0', '1', '0', '1', 'up', 4], ['1', '1', '1', '1', '1', '0', '1', '0', '1', '0', '0', 'up', 8], ['1', '1', '0', '1', '1', '1', '0', '1', '0', '0', '1', 'down', 3], ['0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '0', 'up', 2], ['1', '1', '1', '0', '1', '1', '1', '0', '0', '1', '1', 'up', 4], ['0', '1', '1', '0', '0', '1', '0', '1', '0', '0', '0', 'down', 6], ['1', '1', '1', '1', '0', '0', '0', '1', '1', '0', '0', 'down', 3], ['1', '1', '1', '0', '1', '0', '1', '1', '0', '0', '1', 'down', 4], ['0', '0', '1', '1', '0', '0', '1', '0', '1', '1', '0', 'down', 6], ['1', '1', '1', '0', '0', '1', '1', '0', '1', '0', '0', 'down', 9], ['0', '0', '1', '0', '1', '1', '0', '1', '1', '0', '1', 'up', 4], ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '0', 'up', 5], ['1', '1', '0', '0', '1', '1', '0', '1', '0', '1', '0', 'up', 7], ['1', '0', '0', '0', '1', '0', '1', '1', '0', '1', '1', 'down', 4], ['0', '1', '0', '1', '1', '1', '0', '0', '1', '0', '1', 'up', 10], ['1', '1', '0', '1', '0', '1', '0', '0', '0', '0', '1', 'down', 9], ['1', '0', '1', '1', '0', '0', '1', '1', '1', '0', '0', 'up', 1], ['0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', 'up', 5], ['1', '0', '1', '1', '1', '1', '0', '0', '0', '0', '0', 'down', 8], ['1', '0', '1', '0', '0', '0', '0', '1', '1', '1', '1', 'up', 3], ['1', '0', '0', '0', '1', '1', '0', '0', '0', '1', '0', 'down', 6], ['0', '0', '1', '0', '1', '0', '0', '1', '1', '0', '1', 'down', 5], ['1', '0', '1', '1', '1', '1', '1', '0', '1', '1', '0', 'up', 6], ['1', '0', '1', '0', '1', '1', '1', '1', '1', '0', '1', 'up', 7], ['1', '0', '1', '1', '0', '0', '0', '1', '0', '1', '1', 'down', 2], ['0', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', 'down', 3], ['1', '0', '1', '1', '1', '0', '0', '1', '0', '0', '0', 'down', 4], ['0', '1', '1', '0', '1', '0', '0', '1', '1', '0', '0', 'down', 5], ['0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '0', 'down', 11], ['1', '1', '0', '0', '1', '1', '0', '1', '1', '0', '0', 'up', 5], ['0', '1', '0', '0', '1', '1', '1', '1', '0', '1', '0', 'up', 9], ['1', '1', '0', '1', '1', '0', '0', '0', '1', '1', '0', 'up', 5], ['0', '1', '1', '0', '1', '0', '0', '1', '0', '0', '1', 'down', 5], ['1', '0', '1', '1', '0', '0', '1', '0', '0', '0', '0', 'up', 1], ['1', '1', '0', '0', '0', '1', '1', '0', '1', '1', '1', 'down', 3], ['1', '0', '0', '1', '0', '1', '1', '1', '0', '0', '1', 'down', 2], ['0', '0', '1', '0', '1', '0', '1', '1', '0', '0', '1', 'down', 9], ['0', '0', '0', '0', '1', '0', '1', '0', '1', '0', '0', 'down', 8], ['1', '0', '1', '1', '0', '1', '1', '0', '1', '0', '1', 'down', 3], ['1', '0', '0', '1', '1', '0', '1', '0', '0', '1', '0', 'down', 5], ['1', '1', '0', '0', '0', '1', '1', '1', '0', '0', '1', 'up', 6], ['1', '0', '1', '1', '0', '1', '1', '1', '0', '1', '1', 'up', 9], ['0', '1', '0', '0', '1', '1', '1', '1', '0', '0', '1', 'up', 5], ['0', '1', '0', '1', '0', '1', '1', '1', '0', '0', '1', 'down', 4], ['0', '0', '0', '1', '0', '0', '1', '0', '0', '1', '0', 'down', 8], ['1', '0', '1', '0', '1', '0', '1', '1', '1', '1', '0', 'down', 5], ['1', '0', '1', '0', '0', '1', '0', '0', '0', '1', '0', 'down', 5], ['1', '1', '1', '1', '1', '0', '1', '1', '0', '1', '0', 'up', 6], ['0', '1', '1', '0', '1', '0', '0', '0', '1', '1', '1', 'down', 4], ['0', '0', '1', '0', '0', '1', '1', '0', '0', '1', '1', 'down', 5], ['0', '0', '1', '1', '0', '0', '0', '1', '0', '0', '1', 'up', 3], ['0', '1', '0', '1', '0', '0', '0', '0', '1', '1', '1', 'up', 6], ['0', '1', '0', '1', '0', '0', '1', '0', '1', '0', '0', 'down', 8], ['0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'down', 5], ['1', '0', '0', '0', '1', '0', '1', '1', '0', '0', '0', 'up', 2], ['1', '0', '0', '1', '0', '0', '1', '0', '0', '1', '1', 'down', 9], ['0', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', 'down', 6], ['1', '1', '1', '0', '0', '0', '1', '0', '1', '0', '1', 'up', 5], ['0', '1', '0', '1', '0', '1', '1', '1', '0', '0', '0', 'up', 4], ['1', '0', '1', '1', '0', '1', '1', '1', '0', '1', '0', 'up', 7], ['1', '0', '0', '1', '1', '0', '1', '1', '1', '0', '1', 'down', 2], ['1', '0', '1', '1', '0', '1', '0', '0', '0', '1', '0', 'down', 7], ['0', '1', '1', '1', '1', '0', '1', '0', '0', '1', '0', 'down', 5], ['0', '1', '1', '0', '1', '0', '0', '0', '0', '0', '0', 'down', 2], ['0', '0', '1', '1', '0', '0', '0', '0', '0', '1', '0', 'down', 11], ['1', '1', '0', '0', '0', '0', '1', '1', '1', '0', '0', 'down', 8], ['0', '0', '0', '0', '1', '1', '0', '0', '1', '0', '0', 'up', 1], ['1', '0', '0', '0', '0', '0', '0', '1', '1', '0', '1', 'down', 9], ['1', '0', '0', '0', '0', '1', '0', '1', '1', '0', '1', 'up', 3], ['1', '1', '1', '0', '1', '1', '0', '1', '0', '1', '0', 'up', 14], ['1', '1', '1', '1', '0', '0', '0', '0', '1', '0', '0', 'up', 3], ['1', '0', '1', '1', '0', '0', '1', '1', '0', '1', '1', 'up', 5], ['1', '0', '0', '0', '1', '1', '0', '1', '1', '0', '1', 'up', 9], ['1', '0', '0', '0', '0', '1', '0', '1', '1', '0', '1', 'down', 10], ['1', '1', '1', '1', '0', '1', '0', '1', '0', '0', '0', 'down', 3], ['1', '0', '0', '0', '0', '1', '0', '0', '1', '1', '1', 'down', 6], ['0', '0', '1', '1', '0', '1', '1', '1', '0', '0', '1', 'down', 6], ['1', '1', '1', '1', '1', '0', '1', '0', '0', '0', '0', 'down', 4], ['1', '1', '0', '0', '1', '1', '0', '0', '1', '0', '0', 'down', 9], ['1', '1', '1', '1', '0', '0', '0', '1', '1', '0', '0', 'up', 6], ['0', '1', '0', '1', '0', '0', '1', '1', '0', '1', '0', 'down', 7], ['1', '0', '0', '0', '0', '1', '1', '0', '0', '0', '1', 'down', 8], ['0', '0', '1', '0', '1', '1', '1', '1', '0', '1', '0', 'up', 6]]
#this is the list I am looking for
listB = ['1', '0', '0', '0', '0', '1', '0', '1', '1', '0', '1']
#this is the method I am using to try and find the occurrence of `listB` in `listA`
def fl1(list1, list2):
index = -1
occ = 0
for i, l in enumerate(list2):
if l[:len(list1)] == list1:
if l[-1] > occ:
index = i
occ = l[-1]
if index == -1:
return "The 1st list doesn't appear in the 2nd one."
else:
print(f"The 1st list appears in the 2nd one at index {index} with a number of occurrences equal to {occ}.")
u = "up"
y = "down"
look_up = [(''.join(a[:11]), str(a[11])) if len(a) >= 12 else ('', '') for a in list2]
if (''.join(list1), y) in look_up:
print("down")
if (''.join(list1), u) in look_up:
print("up")
print(fl1(listB, listA))
The output I get proves that both instances of the list exist but I wish for a way for me to use the list with the most occurrences while at the same time identifying whether the string is "up" or "down". How can I do that?
#output
The 1st list appears in the 2nd one at index 579 with a number of occurrences equal to 10.
down
up
None
I don't know if I got what you want, but If other than returning what you already return in your function, you also want to return the list with the highest number of occurrences, you can do that by appending to a list the list that you want to find everytime you find it, and then just return the list with the highest number of occurrences:
#this is the method I am using to try and find the occurrence of `listB` in `listA`
def fl1(list1, list2):
found_lists = [] #The instances of the list you want to find
index = -1
occ = 0
for i, l in enumerate(list2):
if l[:len(list1)] == list1:
if l[-1] > occ:
index = i
occ = l[-1]
found_lists.append(l) #Add the list to the found lists
if index == -1:
return "The 1st list doesn't appear in the 2nd one."
else:
print(f"The 1st list appears in the 2nd one at index {index} with a number of occurrences equal to {occ}.")
u = "up"
y = "down"
look_up = [(''.join(a[:11]), str(a[11])) if len(a) >= 12 else ('', '') for a in list2]
if (''.join(list1), y) in look_up:
print("down")
if (''.join(list1), u) in look_up:
print("up")
print(f"Lists found: {found_lists}")
print(f"List with maximum occurrence: {max(found_lists, key=lambda x: x[-1])}") #Print the list with the maximum number of occurrences, that is expressed by the last element of the list.
print(fl1(listB, listA))
The code prints the following:
The 1st list appears in the 2nd one at index 224 with a number of occurrences equal to 10.
down
up
Lists found: [['1', '0', '0', '0', '0', '1', '0', '1', '1', '0', '1', 'up', 3], ['1', '0', '0', '0', '0', '1', '0', '1', '1', '0', '1', 'down', 10]]
List with maximum occurrence: ['1', '0', '0', '0', '0', '1', '0', '1', '1', '0', '1', 'down', 10]
None
Of course, if you want to use the list, just return it instead of printing it.
The simplest change would be to store it in a variable:
direction = None
if l[-1] > occ:
index = i
occ = l[-1]
direction = l[-2]
found_lists.append(l) #Add the list to the found lists
At the end the direction will contain what you are searching for.
Related
comparison does not allow me to act on the results
I want to know why is it that my if statements are not working. I have code that compares a recently compiled list to a bunch of other lists to see if there is a similar one. The lists are made up of 12 values, direction of the list, and the number of times that same list has occurred. the comparison is done between the first 12 values of each list then what should happen is the position that is found with that list should be identified, however it seems I am unable to call that into action. In essence this is what I want to do... These are the lists I want to compare to one another: list1 = [['1', '1', '1', '1', '1', '0', '1', '0', '1', '0', '1', 'up', 5], ['1', '0', '0', '1', '1', '0', '1', '0', '0', '0', '0', 'up', 2], ['1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '1', 'up', 13], ['1', '0', '0', '1', '1', '0', '1', '1', '0', '0', '1', 'down', 5], ['0', '0', '1', '0', '1', '0', '1', '1', '1', '0', '1', 'up', 8], ['0', '1', '0', '1', '0', '1', '1', '1', '1', '0', '1', 'up', 10], ['0', '1', '1', '1', '0', '0', '0', '0', '1', '1', '0', 'up', 6], ['1', '1', '0', '1', '1', '1', '0', '0', '0', '0', '0', 'down', 8], ['0', '0', '1', '0', '1', '1', '1', '0', '1', '0', '1', 'up', 6], ['0', '1', '0', '1', '0', '0', '0', '0', '0', '0', '1', 'up', 1], ['0', '0', '0', '0', '0', '1', '1', '1', '0', '1', '0', 'up', 3], ['0', '0', '0', '1', '1', '0', '0', '1', '0', '1', '1', 'up', 7], ['1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', 'up', 9], ['0', '0', '0', '1', '0', '0', '0', '0', '1', '0', '1', 'down', 7], ['0', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', 'down', 1]] list2 = ['1', '0', '0', '1', '1', '0', '1', '0', '0', '0', '0'] This is the comparison code I want to use for the lists: def fl(list1, list2): index = -1 occ = 0 for i, l in enumerate(list2): if l[:len(list1)] == list1: if l[-1] > occ: index = i occ = l[-1] if index == -1: return "The first list is not present in the second one." else: print(f"The first lists appears in the second one at index {index} with a number of occurences equal too {occ}.") u = "up" y = "down" lp = [(''.join(a[:6]), a[6]) for a in list2] if (''.join(list1), u) in lp: print("up") elif (''.join(list1), y) in lp: print("down") print(fl(listB, listA)) This is the result I want to get: The first lists appears in the second one at index 2 with a number of occurrences equal to 2. up However what I seem too get is this: The first lists appears in the second one at index 2 with a number of occurrences equal too 2. None Why am I getting none and how can I solve this issue?
I think your problem is caused in the if/elif statement. In general if/elif should be used ONLY when you know that you covered ALL possible scenarios in your code.
How can you sort a list of lists by the number of nonzero elements in each sublist?
I have a list of lists (8 lists of 15 elements each) and it's like below: mylist = [ ['Adam', '0', '1', '0', '1', '0', '1', '0', '0', '1', '0', '1', '0', '1', '0'], ['Bobby', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '1', '1', '0'], ['Felicia', '0', '0', '1', '0', '1', '0', '0', '0', '0', '1', '0', '1', '0', '0'], ['Jake', '0', '1', '1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0'], ['MikeP', '0', '0', '1', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0'], ['MikeF', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], ['Shannon', '0', '1', '0', '0', '1', '0', '0', '0', '0', '1', '0', '1', '0', '0'], ['Tom', '0', '1', '1', '1', '1', '0', '0', '0', '1', '1', '1', '1', '0', '0'] ] Using Python 3, I'm trying to get mylist sorted beginning with the most zeros in a sublist to the fewest zeros in a sublist. I don't want to sort within each list - the 0s and 1s need to stay where they are ultimately. I have tried using len() and lambda functions and other ideas I find here like breaking it down with the following: for index1, value1 in enumerate(mylist): mylistsorted.append([value2 for index2, value2 in enumerate(mylist[index1]) if value2 != '0']) mylistsorted.sort(key = len) But I lose all the '0's of course in that new sorted list. Should this perhaps be done with something else like numpy or matrices or something else vice lists of lists? Thank you for any help...
Use list.count as your key for sorted to count all the 0's in each list: sorted(mylist, key=lambda x: -x[1:].count('0'))
Use a key that counts the number of 0's: mylist.sort( key = lambda l : -l.count('0') )
Taking a not-so-wild guess and counting the ones instead: mylist.sort(key=lambda l: l.count('1'))
How to iterate through a bunch of lists that are inside of a dictionary?
I have this giant dictionary, where I have a key for a key that is a person, and a list of values for each person, here is an example of two people inside of the dictionary: {'NuNu': ['0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '3', '0', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '3', '0', '0', '1', '0', '5', '0', '0', '0', '0', '0', '1', '3', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], 'Hamza ALi': ['0', '0', '0', '0', '0', '0', '0', '-5', '0', '5', '1', '0', '0', '0', '1', '0', '5', '0', '-3', '0', '3', '0', '0', '0', '0', '0', '0', '-5', '0', '0', '-3', '5', '0', '5', '0', '3', '0', '0', '1', '0', '3', '1', '3', '5', '0', '0', '0', '0', '0', '1', '-5', '0', '0', '0', '0']} Now, what I need to do is multiply each value together, like 0 * 0, 0 * 0, etc etc for the entire list of the values, and then add all of the values together. I have already done this in another piece of code, by just for two lists that I put the values inside for. I have no idea how I would do it with a dictionary that has lists inside of it, that are values. list1 = ['0', '0', '0', '5', '0', '0', '0', '5', '0', '5', '5', '0', '0', '0', '0', '0', '5', '-3', '-3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '5', '0', '0', '5', '0', '5', '5', '5', '5', '0', '0', '0', '0', '0', '3', '1', '0', '0', '0', '0'] list2 = ['5', '5', '0', '0', '0', '0', '0', '0', '0', '3', '0', '5', '0', '0', '1', '0', '5', '0', '1', '5', '0', '0', '0', '0', '0', '1', '0', '5', '0', '0', '3', '5', '5', '0', '0', '5', '0', '0', '3', '0', '0', '3', '5', '5', '0', '0', '0', '0', '0', '5', '5', '0', '5', '0', '0'] int_list_1 = map(int,list1) int_list_2 = map(int,list2) third = map(sum, zip(int_list_1, int_list_2)) product = [] for num1, num2 in zip(int_list_1,int_list_2): product.append(num1 * num2) x = sum(product) print(x) ^ This gives me the correct value that I need, but I need help setting this piece of code up for multiple lists that are inside of a dictionary. I know I need to have a for loop, maybe something like this? sum = 0 for value in dict: sum + y print(sum)
This is my solution in general case. Suppose we have n items in dictionary d. Then I make a collection of lists with integer values like so: vals = map(lambda x: [int(n) for n in x], d.values()) After that I get all the tuples of items that is going to be multiplied elementwise: p = zip(*vals) Finally, this is a way to calculate all the products: #from functools import reduce products = [reduce(lambda x,y: x*y, n) for n in p] output = sum(products) Alternative way Since lengths of dictionary values are balanced, we can use numpy actions: import numpy as np vals = np.array(list(d.values())).astype(int) products = np.prod(vals, axis=0) output = np.sum(products)
You try this. a={'NuNu': ['0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '3', '0', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '3', '0', '0', '1', '0', '5', '0', '0', '0', '0', '0', '1', '3', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], 'Hamza ALi': ['0', '0', '0', '0', '0', '0', '0', '-5', '0', '5', '1', '0', '0', '0', '1', '0', '5', '0', '-3', '0', '3', '0', '0', '0', '0', '0', '0', '-5', '0', '0', '-3', '5', '0', '5', '0', '3', '0', '0', '1', '0', '3', '1', '3', '5', '0', '0', '0', '0', '0', '1', '-5', '0', '0', '0', '0']} x,y=a.values() x=map(int,x) y=map(int,y) out=[i*j for i,j in zip(x,y)] print(out) print(sum(out)) [0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, 0, 0, 5, 0, 15, 0, 0, 0, 0, 0, 1, 9, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 37
Another way is to use the reduce function: from functools import reduce inDict = {'NuNu': ['0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '3', '0', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '3', '0', '0', '1', '0', '5', '0', '0', '0', '0', '0', '1', '3', '3', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], 'Hamza ALi': ['0', '0', '0', '0', '0', '0', '0', '-5', '0', '5', '1', '0', '0', '0', '1', '0', '5', '0', '-3', '0', '3', '0', '0', '0', '0', '0', '0', '-5', '0', '0', '-3', '5', '0', '5', '0', '3', '0', '0', '1', '0', '3', '1', '3', '5', '0', '0', '0', '0', '0', '1', '-5', '0', '0', '0', '0']} result = sum([reduce(lambda x,y: x*y, map(int,elem)) for elem in zip(*inDict.values())]) print(result) Output: 37
You've got the right idea. What about something like this for dicts with any number of keys. def mul(iterable): t = 1 for i in iterable: t *= int(i) return t z = zip(*a.values()) # => [('0', '0'), ('0', '0'), ...] m = map(mul, z) # => [0, 0, ...] print(sum(m)) # => 37 Edit You could replace the mul function with functools.reduce from functools import reduce z = zip(*a.values()) m = map(lambda t: reduce(lambda x, y: int(x) * int(y), t), z) print(sum(m)) Now all as one line: print(sum(map(lambda t: reduce(lambda x, y: int(x) * int(y), t), zip(*a.values()))))
Convert list of string into comma separated 2D NumPy
I have a dataset like the following: 0000000000000001,0 0000000000000010,0 0000000000000011,1 0000000000000100,1 0000000000000101,1 0000000000000110,0 0000000000000111,1 0000000000001000,0 0000000000001001,0 . . . I want to convert the first column from each row to be a comma seperated something like this: From 0000000000000001,0 to 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 The following code has a small issue: full_data is not 2D numpy of integers, yet it is 1D of string. I am not sure how to fix that. Any hint is appreciated. data = [] my_data = np.genfromtxt('file.csv', delimiter=',', dtype='str')[:,0] for i in my_data: x= np.asarray(i) data.append(x.tolist()) full_data = np.asarray(data) Thank you
This is one approach. Demo: import numpy as np data = [] my_data = np.genfromtxt(filename, delimiter=',', dtype='str') data = [list(i) + [j] for i, j in my_data] print(data) Output: [ ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '1', '1'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0'], ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0'] ]
XML Parsing to .txt file Python
I need to parse this XML Document and move the date and time into a %Y-%m-%d %H:%M:%S format as well as the variables hourly-qpf and probability-of-precipitation to columns in a tab-delimited .txt file. All I have managed to do is read in the XML file using this code: page = urllib2.urlopen('http://forecast.weather.gov/MapClick.php?lat=47.6062&lon=-122.3321&FcstType=digitalDWML') page_content = page.read() with open('KBFI.xml', 'w') as fid: fid.write(page_content) I am at a loss after this. I've only parsed one XML doc before, and it looked completely different from this. EDIT Sorry for not having anything to give you guys before, but I wasn't sure what module to use, as I only have experience with minidom and it didn't seem like the right choice. I've been messing around with Element Tree and I have come up with this: data = [] import xml.etree.ElementTree as ET tree = ET.parse('KBFI.xml') root = tree.getroot() for data in root.findall('data'): for time-layout in root.findall('time-layout'): start-valid-time = time-layout.find('start-valid-time') time = datetime.datetime.strptime(start-valid-time, '%Y-%m-%dT%H:%M:%S') for parameters in root.findall('parameters'): for probability-of-precipitation in root.findall('probability-of-precipitation'): value = probability-of-precipitation.find('value') for hourly-qpf in root.findall('hourly-qpf'): value2 = hourly-qpf.find('value') data = data.append([time, value, value2]) with open('KBFI.txt','w') as file: file.writelines('\t'.join(map(str,i)) + '\n' for i in data) However, there is a problem because the variables are hyphenated and I do not know how to change them to underscores or remove them. Also, because of this, I have no idea if my code is any good!
You can use the python xml lib: https://docs.python.org/2/library/xml.etree.elementtree.html import urllib2 import xml.etree.ElementTree as ET page = urllib2.urlopen('http://forecast.weather.gov/MapClick.php?lat=47.6062&lon=-122.3321&FcstType=digitalDWML') page_content = page.read() root = ET.fromstring(page_content) for _f in root.itertext(): ***Do your formatting here***
I suggest using xmltodict for parsing and extracting data from XML because it is straightforward and easy to use since it converts XML to Python dicts with the same nesting as the XML source. For those familiar with Python syntax, using it is natural and Python dicts are fully versatile, meaning they are capable of expressing heterogeneous and nested data stuctures. For example the Pickling Tools Library relies on Python dicts for Python, C++ and Java data interoperability and provides tools for converting XML to dict. Advantages of xmltodict are that its small, fast, and a standalone module just for converting XML to dict. As an example of xmltodict usage, the following script downloads this XML document and extracts its creation-date and lists of probability-of-precipitation and hourly-qpf values: import requests url='http://forecast.weather.gov/MapClick.php?lat=47.6062&lon=-122.3321&FcstType=digitalDWML' r = requests.get(url) import xmltodict result = xmltodict.parse(r.text) cd = result['dwml']['head']['product']['creation-date']['#text'] print("creation-date =",cd) pop = result['dwml']['data']['parameters']['probability-of-precipitation']['value'] print("\nprobability-of-precipitation =", pop) hqpf = result['dwml']['data']['parameters']['hourly-qpf']['value'] print("\nhourly-qpf =", hqpf) Here is the output from running this script (on 20150730): creation-date = 2015-07-30T08:53:12-07:00 probability-of-precipitation = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '13', '13', '13', '13', '13', '13', '13', '13', '13', '13', '13', '13', '19', '19', '19', '19', '19', '19', '19', '19', '19', '19', '19', '19', '28', '28', '28', '28', '28', '28'] hourly-qpf = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0.0067', '0.0067', '0.0067', '0.0067', '0.0067', '0.0067', '0.0033', '0.0033', '0.0033', '0.0033', '0.0033', '0.0033', '0.0067', '0.0067', '0.0067', '0.0067', '0.0067', '0.0067'] xmltodict can be installed with 'pip install xmltodict'. It was developed by Martin Blech and its GitHub project is at https://github.com/martinblech/xmltodict. In order to access start-valid-time and end-valid-time its helps to know their data structures as well their locations. Since both are a series of values enclosed in identical tags, intuitively each series should be formed in a separate list as the value of a key with their name similar to probability-of-precipitation and hourly-qpf. This can be confirmed by printing the entire result dict and inspecting the format of start-valid-time and end-valid-time in it and that can be facilitated by pretty printing the result dict (with import pprint and then running pprint.pprint(result)). For this XML document, pretty printing its equivilant dict generates over 2000 lines, however start-valid-time begins on line 26 and its value is clearly an list: {'dwml': {'#version': '1.0', '#xmlns:xsd': 'http://www.w3.org/2001/XMLSchema', '#xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', '#xsi:noNamespaceSchemaLocation': 'http://graphical.weather.gov/xml/DWMLgen/schema/DWML.xsd', 'head': {'product': {'#concise-name': 'tabular-digital', '#operational-mode': 'developmental', '#srsName': 'WGS 1984', 'creation-date': {'#refresh-frequency': 'PT1H', '#text': '2015-07-31T14:20:30-07:00'}}, 'source': {'production-center': 'Seattle, WA', 'credit': 'http://www.wrh.noaa.gov/sew', 'more-information': 'http://www.nws.noaa.gov/forecasts/xml/'}}, 'data': {'location': {'location-key': 'point1', 'description': 'Downtown Seattle WA, WA', 'point': {'#latitude': '47.61', '#longitude': '-122.32'}, 'city': {'#state': 'WA', '#text': 'Downtown Seattle WA'}, 'height': {'#datum': 'mean sea level', '#text': '240'}}, 'moreWeatherInformation': {'#applicable-location': 'point1', '#text': 'http://forecast.weather.gov/MapClick.php?lat=47.61&lon=-122.32&FcstType=digital'}, 'time-layout': {'#time-coordinate': 'local', '#summarization': 'none', 'layout-key': 'k-p1h-n1-0', 'start-valid-time': ['2015-07-31T16:00:00-07:00', '2015-07-31T17:00:00-07:00', '2015-07-31T18:00:00-07:00', ... Here is a script that extracts and prints creation-date as a scalar value, all start-valid-time values in a list, all end-valid-time values in a list, all probability-of-precipitation values in a list and all hourly-qpf values in a list and prints the length of each extracted list: import xmltodict result = xmltodict.parse(r.text) cd = result['dwml']['head']['product']['creation-date']['#text'] print("creation-date =",cd) svt = result['dwml']['data']['time-layout']['start-valid-time'] print("\nstart-valid-time =", svt) print("number of start-valid-time entries =", len(svt)) evt = result['dwml']['data']['time-layout']['end-valid-time'] print("\nend-valid-time =", evt) print("number of end-valid-time entries =", len(evt)) pop = result['dwml']['data']['parameters']['probability-of-precipitation']['value'] print("\nprobability-of-precipitation =", pop) print("number of probability-of-precipitation entries =", len(pop)) hqpf = result['dwml']['data']['parameters']['hourly-qpf']['value'] print("\nhourly-qpf =", hqpf) print("number of hourly-qpf entries =", len(hqpf)) Here is the output from running this script (on 20150731): creation-date = 2015-07-31T14:20:30-07:00 start-valid-time = ['2015-07-31T16:00:00-07:00', '2015-07-31T17:00:00-07:00', '2015-07-31T18:00:00-07:00', '2015-07-31T19:00:00-07:00', '2015-07-31T20:00:00-07:00', '2015-07-31T21:00:00-07:00', '2015-07-31T22:00:00-07:00', '2015-07-31T23:00:00-07:00', '2015-08-01T00:00:00-07:00', '2015-08-01T01:00:00-07:00', '2015-08-01T02:00:00-07:00', '2015-08-01T03:00:00-07:00', '2015-08-01T04:00:00-07:00', '2015-08-01T05:00:00-07:00', '2015-08-01T06:00:00-07:00', '2015-08-01T07:00:00-07:00', '2015-08-01T08:00:00-07:00', '2015-08-01T09:00:00-07:00', '2015-08-01T10:00:00-07:00', '2015-08-01T11:00:00-07:00', '2015-08-01T12:00:00-07:00', '2015-08-01T13:00:00-07:00', '2015-08-01T14:00:00-07:00', '2015-08-01T15:00:00-07:00', '2015-08-01T16:00:00-07:00', '2015-08-01T17:00:00-07:00', '2015-08-01T18:00:00-07:00', '2015-08-01T19:00:00-07:00', '2015-08-01T20:00:00-07:00', '2015-08-01T21:00:00-07:00', '2015-08-01T22:00:00-07:00', '2015-08-01T23:00:00-07:00', '2015-08-02T00:00:00-07:00', '2015-08-02T01:00:00-07:00', '2015-08-02T02:00:00-07:00', '2015-08-02T03:00:00-07:00', '2015-08-02T04:00:00-07:00', '2015-08-02T05:00:00-07:00', '2015-08-02T06:00:00-07:00', '2015-08-02T07:00:00-07:00', '2015-08-02T08:00:00-07:00', '2015-08-02T09:00:00-07:00', '2015-08-02T10:00:00-07:00', '2015-08-02T11:00:00-07:00', '2015-08-02T12:00:00-07:00', '2015-08-02T13:00:00-07:00', '2015-08-02T14:00:00-07:00', '2015-08-02T15:00:00-07:00', '2015-08-02T16:00:00-07:00', '2015-08-02T17:00:00-07:00', '2015-08-02T18:00:00-07:00', '2015-08-02T19:00:00-07:00', '2015-08-02T20:00:00-07:00', '2015-08-02T21:00:00-07:00', '2015-08-02T22:00:00-07:00', '2015-08-02T23:00:00-07:00', '2015-08-03T00:00:00-07:00', '2015-08-03T01:00:00-07:00', '2015-08-03T02:00:00-07:00', '2015-08-03T03:00:00-07:00', '2015-08-03T04:00:00-07:00', '2015-08-03T05:00:00-07:00', '2015-08-03T06:00:00-07:00', '2015-08-03T07:00:00-07:00', '2015-08-03T08:00:00-07:00', '2015-08-03T09:00:00-07:00', '2015-08-03T10:00:00-07:00', '2015-08-03T11:00:00-07:00', '2015-08-03T12:00:00-07:00', '2015-08-03T13:00:00-07:00', '2015-08-03T14:00:00-07:00', '2015-08-03T15:00:00-07:00', '2015-08-03T16:00:00-07:00', '2015-08-03T17:00:00-07:00', '2015-08-03T18:00:00-07:00', '2015-08-03T19:00:00-07:00', '2015-08-03T20:00:00-07:00', '2015-08-03T21:00:00-07:00', '2015-08-03T22:00:00-07:00', '2015-08-03T23:00:00-07:00', '2015-08-04T00:00:00-07:00', '2015-08-04T01:00:00-07:00', '2015-08-04T02:00:00-07:00', '2015-08-04T03:00:00-07:00', '2015-08-04T04:00:00-07:00', '2015-08-04T05:00:00-07:00', '2015-08-04T06:00:00-07:00', '2015-08-04T07:00:00-07:00', '2015-08-04T08:00:00-07:00', '2015-08-04T09:00:00-07:00', '2015-08-04T10:00:00-07:00', '2015-08-04T11:00:00-07:00', '2015-08-04T12:00:00-07:00', '2015-08-04T13:00:00-07:00', '2015-08-04T14:00:00-07:00', '2015-08-04T15:00:00-07:00', '2015-08-04T16:00:00-07:00', '2015-08-04T17:00:00-07:00', '2015-08-04T18:00:00-07:00', '2015-08-04T19:00:00-07:00', '2015-08-04T20:00:00-07:00', '2015-08-04T21:00:00-07:00', '2015-08-04T22:00:00-07:00', '2015-08-04T23:00:00-07:00', '2015-08-05T00:00:00-07:00', '2015-08-05T01:00:00-07:00', '2015-08-05T02:00:00-07:00', '2015-08-05T03:00:00-07:00', '2015-08-05T04:00:00-07:00', '2015-08-05T05:00:00-07:00', '2015-08-05T06:00:00-07:00', '2015-08-05T07:00:00-07:00', '2015-08-05T08:00:00-07:00', '2015-08-05T09:00:00-07:00', '2015-08-05T10:00:00-07:00', '2015-08-05T11:00:00-07:00', '2015-08-05T12:00:00-07:00', '2015-08-05T13:00:00-07:00', '2015-08-05T14:00:00-07:00', '2015-08-05T15:00:00-07:00', '2015-08-05T16:00:00-07:00', '2015-08-05T17:00:00-07:00', '2015-08-05T18:00:00-07:00', '2015-08-05T19:00:00-07:00', '2015-08-05T20:00:00-07:00', '2015-08-05T21:00:00-07:00', '2015-08-05T22:00:00-07:00', '2015-08-05T23:00:00-07:00', '2015-08-06T00:00:00-07:00', '2015-08-06T01:00:00-07:00', '2015-08-06T02:00:00-07:00', '2015-08-06T03:00:00-07:00', '2015-08-06T04:00:00-07:00', '2015-08-06T05:00:00-07:00', '2015-08-06T06:00:00-07:00', '2015-08-06T07:00:00-07:00', '2015-08-06T08:00:00-07:00', '2015-08-06T09:00:00-07:00', '2015-08-06T10:00:00-07:00', '2015-08-06T11:00:00-07:00', '2015-08-06T12:00:00-07:00', '2015-08-06T13:00:00-07:00', '2015-08-06T14:00:00-07:00', '2015-08-06T15:00:00-07:00', '2015-08-06T16:00:00-07:00', '2015-08-06T17:00:00-07:00', '2015-08-06T18:00:00-07:00', '2015-08-06T19:00:00-07:00', '2015-08-06T20:00:00-07:00', '2015-08-06T21:00:00-07:00', '2015-08-06T22:00:00-07:00', '2015-08-06T23:00:00-07:00', '2015-08-07T00:00:00-07:00', '2015-08-07T01:00:00-07:00', '2015-08-07T02:00:00-07:00', '2015-08-07T03:00:00-07:00', '2015-08-07T04:00:00-07:00', '2015-08-07T05:00:00-07:00', '2015-08-07T06:00:00-07:00', '2015-08-07T07:00:00-07:00', '2015-08-07T08:00:00-07:00', '2015-08-07T09:00:00-07:00', '2015-08-07T10:00:00-07:00', '2015-08-07T11:00:00-07:00', '2015-08-07T12:00:00-07:00', '2015-08-07T13:00:00-07:00', '2015-08-07T14:00:00-07:00', '2015-08-07T15:00:00-07:00'] number of start-valid-time entries = 168 end-valid-time = ['2015-07-31T17:00:00-07:00', '2015-07-31T18:00:00-07:00', '2015-07-31T19:00:00-07:00', '2015-07-31T20:00:00-07:00', '2015-07-31T21:00:00-07:00', '2015-07-31T22:00:00-07:00', '2015-07-31T23:00:00-07:00', '2015-08-01T00:00:00-07:00', '2015-08-01T01:00:00-07:00', '2015-08-01T02:00:00-07:00', '2015-08-01T03:00:00-07:00', '2015-08-01T04:00:00-07:00', '2015-08-01T05:00:00-07:00', '2015-08-01T06:00:00-07:00', '2015-08-01T07:00:00-07:00', '2015-08-01T08:00:00-07:00', '2015-08-01T09:00:00-07:00', '2015-08-01T10:00:00-07:00', '2015-08-01T11:00:00-07:00', '2015-08-01T12:00:00-07:00', '2015-08-01T13:00:00-07:00', '2015-08-01T14:00:00-07:00', '2015-08-01T15:00:00-07:00', '2015-08-01T16:00:00-07:00', '2015-08-01T17:00:00-07:00', '2015-08-01T18:00:00-07:00', '2015-08-01T19:00:00-07:00', '2015-08-01T20:00:00-07:00', '2015-08-01T21:00:00-07:00', '2015-08-01T22:00:00-07:00', '2015-08-01T23:00:00-07:00', '2015-08-02T00:00:00-07:00', '2015-08-02T01:00:00-07:00', '2015-08-02T02:00:00-07:00', '2015-08-02T03:00:00-07:00', '2015-08-02T04:00:00-07:00', '2015-08-02T05:00:00-07:00', '2015-08-02T06:00:00-07:00', '2015-08-02T07:00:00-07:00', '2015-08-02T08:00:00-07:00', '2015-08-02T09:00:00-07:00', '2015-08-02T10:00:00-07:00', '2015-08-02T11:00:00-07:00', '2015-08-02T12:00:00-07:00', '2015-08-02T13:00:00-07:00', '2015-08-02T14:00:00-07:00', '2015-08-02T15:00:00-07:00', '2015-08-02T16:00:00-07:00', '2015-08-02T17:00:00-07:00', '2015-08-02T18:00:00-07:00', '2015-08-02T19:00:00-07:00', '2015-08-02T20:00:00-07:00', '2015-08-02T21:00:00-07:00', '2015-08-02T22:00:00-07:00', '2015-08-02T23:00:00-07:00', '2015-08-03T00:00:00-07:00', '2015-08-03T01:00:00-07:00', '2015-08-03T02:00:00-07:00', '2015-08-03T03:00:00-07:00', '2015-08-03T04:00:00-07:00', '2015-08-03T05:00:00-07:00', '2015-08-03T06:00:00-07:00', '2015-08-03T07:00:00-07:00', '2015-08-03T08:00:00-07:00', '2015-08-03T09:00:00-07:00', '2015-08-03T10:00:00-07:00', '2015-08-03T11:00:00-07:00', '2015-08-03T12:00:00-07:00', '2015-08-03T13:00:00-07:00', '2015-08-03T14:00:00-07:00', '2015-08-03T15:00:00-07:00', '2015-08-03T16:00:00-07:00', '2015-08-03T17:00:00-07:00', '2015-08-03T18:00:00-07:00', '2015-08-03T19:00:00-07:00', '2015-08-03T20:00:00-07:00', '2015-08-03T21:00:00-07:00', '2015-08-03T22:00:00-07:00', '2015-08-03T23:00:00-07:00', '2015-08-04T00:00:00-07:00', '2015-08-04T01:00:00-07:00', '2015-08-04T02:00:00-07:00', '2015-08-04T03:00:00-07:00', '2015-08-04T04:00:00-07:00', '2015-08-04T05:00:00-07:00', '2015-08-04T06:00:00-07:00', '2015-08-04T07:00:00-07:00', '2015-08-04T08:00:00-07:00', '2015-08-04T09:00:00-07:00', '2015-08-04T10:00:00-07:00', '2015-08-04T11:00:00-07:00', '2015-08-04T12:00:00-07:00', '2015-08-04T13:00:00-07:00', '2015-08-04T14:00:00-07:00', '2015-08-04T15:00:00-07:00', '2015-08-04T16:00:00-07:00', '2015-08-04T17:00:00-07:00', '2015-08-04T18:00:00-07:00', '2015-08-04T19:00:00-07:00', '2015-08-04T20:00:00-07:00', '2015-08-04T21:00:00-07:00', '2015-08-04T22:00:00-07:00', '2015-08-04T23:00:00-07:00', '2015-08-05T00:00:00-07:00', '2015-08-05T01:00:00-07:00', '2015-08-05T02:00:00-07:00', '2015-08-05T03:00:00-07:00', '2015-08-05T04:00:00-07:00', '2015-08-05T05:00:00-07:00', '2015-08-05T06:00:00-07:00', '2015-08-05T07:00:00-07:00', '2015-08-05T08:00:00-07:00', '2015-08-05T09:00:00-07:00', '2015-08-05T10:00:00-07:00', '2015-08-05T11:00:00-07:00', '2015-08-05T12:00:00-07:00', '2015-08-05T13:00:00-07:00', '2015-08-05T14:00:00-07:00', '2015-08-05T15:00:00-07:00', '2015-08-05T16:00:00-07:00', '2015-08-05T17:00:00-07:00', '2015-08-05T18:00:00-07:00', '2015-08-05T19:00:00-07:00', '2015-08-05T20:00:00-07:00', '2015-08-05T21:00:00-07:00', '2015-08-05T22:00:00-07:00', '2015-08-05T23:00:00-07:00', '2015-08-06T00:00:00-07:00', '2015-08-06T01:00:00-07:00', '2015-08-06T02:00:00-07:00', '2015-08-06T03:00:00-07:00', '2015-08-06T04:00:00-07:00', '2015-08-06T05:00:00-07:00', '2015-08-06T06:00:00-07:00', '2015-08-06T07:00:00-07:00', '2015-08-06T08:00:00-07:00', '2015-08-06T09:00:00-07:00', '2015-08-06T10:00:00-07:00', '2015-08-06T11:00:00-07:00', '2015-08-06T12:00:00-07:00', '2015-08-06T13:00:00-07:00', '2015-08-06T14:00:00-07:00', '2015-08-06T15:00:00-07:00', '2015-08-06T16:00:00-07:00', '2015-08-06T17:00:00-07:00', '2015-08-06T18:00:00-07:00', '2015-08-06T19:00:00-07:00', '2015-08-06T20:00:00-07:00', '2015-08-06T21:00:00-07:00', '2015-08-06T22:00:00-07:00', '2015-08-06T23:00:00-07:00', '2015-08-07T00:00:00-07:00', '2015-08-07T01:00:00-07:00', '2015-08-07T02:00:00-07:00', '2015-08-07T03:00:00-07:00', '2015-08-07T04:00:00-07:00', '2015-08-07T05:00:00-07:00', '2015-08-07T06:00:00-07:00', '2015-08-07T07:00:00-07:00', '2015-08-07T08:00:00-07:00', '2015-08-07T09:00:00-07:00', '2015-08-07T10:00:00-07:00', '2015-08-07T11:00:00-07:00', '2015-08-07T12:00:00-07:00', '2015-08-07T13:00:00-07:00', '2015-08-07T14:00:00-07:00', '2015-08-07T15:00:00-07:00', '2015-08-07T16:00:00-07:00'] number of end-valid-time entries = 168 probability-of-precipitation = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '13', '13', '13', '13', '13', '13', '13', '13', '13', '13', '13', '13', '23', '23', '23', '23', '23', '23', '23', '23', '23', '23', '23', '23', '12', '12', '12', '12', '12', '12', '12', '12', '12', '12', '12', '12', '34', '34', '34', '34', '34', '34', '34', '34', '34', '34', '34'] number of probability-of-precipitation entries = 168 hourly-qpf = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0.0050', '0.0050', '0.0050', '0.0050', '0.0050', '0.0050', '0.0033', '0.0033', '0.0033', '0.0033', '0.0033', '0.0033', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0.0017', '0.0017', '0.0017', '0.0017', '0.0017', '0.0017', '0.0083', '0.0083', '0.0083', '0.0083', '0.0083'] number of hourly-qpf entries = 168