1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # LAB 12-1 ¿ï¸ªµµ´Â ¸î ¿ù¿¡ ¹Ù¶÷ÀÌ °¡Àå °ÇÒ±î?, 311ÂÊ # import csv import matplotlib.pyplot as plt f = open('d:/data/weather.csv') # CSV ÆÄÀÏ ¿¾î f¿¡ ÀúÀå data = csv.reader(f) # reader() ÇÔ¼ö·Î Àбâ header = next(data) # Çì´õ¸¦ Á¦°Å monthly_wind = [ 0 for x in range(12) ] # ¸Å´Þ dz¼ÓÀ» ´ãÀ» ¸®½ºÆ® days_counted = [ 0 for x in range(12) ] # °¢ ´Þ¸¶´Ù ÃøÁ¤µÈ Àϼö for row in data: month = int(row[0][5:7]) # 0¹ø ¿¿¡¼ ´Þ Á¤º¸ ÃßÃâ if row[3] != '' : # dz¼Ó µ¥ÀÌÅÍ Á¸ÀçÇÏ´ÂÁö È®ÀÎ wind = float(row[3]) # dz¼ÓÀ» ¾ò¾î ¿Â´Ù. monthly_wind[month-1] += wind # ÇØ´ç ´Þ¿¡ dz¼Ó µ¥ÀÌÅÍ Ãß°¡ days_counted[month-1] += 1 # ÇØ´ç ´ÞÀÇ Àϼö¸¦ Áõ°¡ for i in range(12) : monthly_wind[i] /= days_counted[i] # Àϼö·Î ³ª´©¾î ¿ùÆò±Õ ±¸Çϱâ print(monthly_wind) plt.plot(monthly_wind, 'blue') plt.show() f.close() # ÆÄÀÏÀ» ´Ý´Â´Ù. | cs |