画像処理特論 - Advanced Topics in Image Processing May 1st 2026, Coding 3

Session Guide: Beginners: Dictionaries, definitions (keys and values), how to create a dictionary: Please check: [UNIT 3, Dictionaries,](https://colab.research.google.com/dri...) Use Dictionaries to find how many times every wind direction in project 1 is repeated: Previously we) Opened the file, jumped the first line with "next" and processed each line with "split" to create a list of strings. In this session you should: 1) Go over the list of wind directions for every line. 2) For every wind direction, add one to a dictionary pair whose KEY is the wind direction itself and the VALUE the number of times the value has been repeated. You will need an "if" to check if the wind direction is already in the dictionary or a defaultDict (https://docs.python.org/3/library/col...) You can solve this exercise by first creating a list of tuples as suggested. If you do, check [UNIT 2, Tuples,](https://colab.research.google.com/dri...) Advanced: 1) From each line in the windDirection file, create a tuple as indicated in the text of the exercise. Create a list of tuples by iterating over all lines. Do this with a simple loop, then transform the inside of the loop into a function and finally get rid of the loop with a map. 2) Process the resulting list of tuples to create the dictionary. Use defaultdict to make the code more compact. What should be done with incorrect values? 3) Use pandas (count, or value count, you may also want to look into "stack") to create the same dictionary. 4) Improve the code using maps, measure the time of the three options.