My data looks as follows:
data = [
{'order': 1, 'operation': 'milling', 'duration': 70, 'position': 1, 'start': 0, 'end': 70}
{'order': 1, 'operation': 'milling', 'duration': 20, 'position': 2, 'start': 200, 'end': 210}
{'order': 1, 'operation': 'milling', 'duration': 100, 'position': 2, 'start': 500, 'end': 600}
{'order': 1, 'operation': 'grinding', 'duration': 60, 'position': 3, 'start': 90, 'end': 150}
{'order': 2, 'operation': 'grinding', 'duration': 20, 'position': 1, 'start': 150, 'end': 170}
{'order': 3, 'operation': 'grinding', 'duration': 20, 'position': 1, 'start': 400, 'end': 420}
{'order': 3, 'operation': 'milling', 'duration': 50, 'position': 1, 'start': 610, 'end': 660}
]
Now I want to calculate the maximum gaps of each operation. Operation 'milling' has its maximum gap between 210 and 500. Operation 'grinding' has its maximum gap between 170 and 400.
How to extract these maximum gaps to a new dictionary?
max_gaps = [
{'operation': 'milling', 'max_gap': 290, 'start': 210, 'end': 500}
{'operation': 'grinding', 'max_gap': 230, 'start': 170, 'end': 400}
]