Created
December 18, 2016 10:07
-
-
Save kendhia/d7d47871f165e071b17f1f211353a094 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import matplotlib.pyplot as plot | |
csvReader = csv.reader(open("weather_2012.csv")) | |
weatherCsvList = list(csvReader) | |
weatherDic = {} | |
weatherMeanDegree = [] | |
for i in range(1, len(weatherCsvList)): | |
if weatherCsvList[i][7] in weatherDic: | |
weatherDic[weatherCsvList[i][7]].append(float(weatherCsvList[i][1])) | |
else: | |
weatherDic[weatherCsvList[i][7]] = [float(weatherCsvList[i][1])] | |
for key in weatherDic: | |
meanValue = 0 | |
for i in weatherDic[key]: | |
meanValue += i | |
weatherDic[key] = meanValue / len(weatherDic[key]) | |
for key in sorted(weatherDic): | |
print(key, " ", weatherDic[key]) | |
listOfSortedKeys = sorted(weatherDic) | |
listOfSortedValues = [] | |
for key in listOfSortedKeys : | |
listOfSortedValues.append(weatherDic[key]) | |
x_axis = [x for x in range(len(listOfSortedKeys))] | |
y_axis = listOfSortedValues | |
plot.bar(x_axis, y_axis, color='y',bottom=-15) | |
plot.xticks(x_axis, list(weatherDic.keys()), rotation=45, fontsize="5") | |
plot.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment