This repository was archived by the owner on Dec 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathusc.py
More file actions
39 lines (30 loc) · 1.18 KB
/
usc.py
File metadata and controls
39 lines (30 loc) · 1.18 KB
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
30
31
32
33
34
35
36
37
38
39
from os.path import expanduser
import pandas
import matplotlib.pyplot as plt
import numpy
df = pandas.DataFrame.from_csv(expanduser('~/Desktop/usc.csv'), index_col=False)
df.Country.value_counts() # total by country
for place in ['Gold', 'Silver', 'Bronze']: # g,s,b by sport
print '\n\n', place, '\n'
df[df['Place'] == place]['Sport'].value_counts()
df.Year.value_counts() # total per year
#df.Year.value_counts().sort_index().plot()
#plt.show()
def getColor(country):
if country == "United States":
return numpy.array((153, 0, 0)) / 255.0
if country == "Great Britain":
country = 'United Kingdom'
if country == 'West Germany':
country = 'Germany'
if country in df.Country.value_counts():
return numpy.array((255, 204, 0)) / 255.0
else:
return numpy.array((255,255,255)) / 255.0
from cartopy import crs
from cartopy.io import shapereader
countries = shapereader.natural_earth(resolution='110m', category='cultural', name='admin_0_countries')
ax = plt.axes(projection=crs.PlateCarree())
for country in shapereader.Reader(countries).records():
ax.add_geometries(country.geometry, crs.PlateCarree(), facecolor=getColor(country.attributes['name_long']))
plt.show()