This repository has been 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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83ab438
commit 796d15f
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |