In [1]:
import pandas as pd
import seaborn
import matplotlib.pyplot as plt
In [2]:
data = pd.read_csv('cgc-full.csv', error_bad_lines=False)
D:\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:2717: DtypeWarning: Columns (17,18,19,20,22,24,25,26,27,28,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,58,60,63,65,66,67,69,70,71,72,73,74,75,76,77,78,80,81) have mixed types. Specify dtype option on import or set low_memory=False.
  interactivity=interactivity, compiler=compiler, result=result)
In [3]:
data.head()
Out[3]:
No data shown due to privacy
In [4]:
total = data.groupby('country').size().nlargest(10)
total
Out[4]:
country
United Kingdom    13830
Germany           13443
Italy              8231
Netherlands        5969
Greece             5295
Canada             5034
Australia          4571
Poland             4246
Russia             4114
Malaysia           3043
dtype: int64
In [5]:
precent = total[0]+total[1]+total[2]+total[3]+total[4]+total[5]+total[6]+total[7]+total[8]+total[9]

ob1 = total[0]/precent*100
ob2 = total[1]/precent*100
ob3 = total[2]/precent*100
ob4 = total[3]/precent*100
ob5 = total[4]/precent*100
ob6 = total[5]/precent*100
ob7 = total[6]/precent*100
ob8 = total[7]/precent*100
ob9 = total[8]/precent*100
ob10 = total[9]/precent*100
In [8]:
labels = total[0:1],total[1:2],total[2:3],total[3:4],total[4:5],total[5:6],total[6:7],total[7:8],total[8:9],total[9:10]
sizes = [ob1,ob2,ob3,ob4,ob5,ob6,ob7,ob8,ob9,ob10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral', 'silver', 'blue', 'pink', 'red', 'grey', 'orange']
explode = (0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.3,0.4,0.5)  # "explode" Slices for looks

plt.pie(sizes, explode=explode, labels=labels, colors=colors,
        autopct='%1.1f%%', shadow=True, startangle=90)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')

plt.show()