# Crosscompute
target_folder = '/tmp'
import pandas
import matplotlib
from matplotlib import pyplot as plt
d = pandas.read_csv('NYC_Social_Media_Usage.csv')
t = d[['Platform', 'Likes/Followers/Visits/Downloads']]
t
t = t.dropna()
t
labels = t.Platform.values
values=t['Likes/Followers/Visits/Downloads'].values
s = t.groupby('Platform').sum()
t.columns
d = pandas.read_csv('NYC_Social_Media_Usage.csv')
t = d[['Platform', 'Likes/Followers/Visits/Downloads']]
t = t.dropna()
labels = t.Platform.values
values=t['Likes/Followers/Visits/Downloads'].values
s = t.groupby('Platform').sum()
s.index
s = s.drop('TOTAL')
f3,ax3=plt.subplots()
ax3.pie(s.values, labels=s.index)
ax3.axis('equal')
s.plot.pie(s.columns[0])
f3,ax3=plt.subplots()
ax3.axis('equal')
s.plot(y=s.columns[0], kind='pie', labels=['' for x in range(len(s.index))], ax=ax3, title=s.index.name, fontsize=10)
ax3.legend(loc=3, labels=s.index,bbox_to_anchor=(-0.30,0))
ax3.set_ylabel('')
s.columns
s.loc['foursquare'] = s.loc['Foursquare'] + s.loc['Foursquare (Badge Unlock)']
s
s = s.drop('Foursquare')
s = s.drop('Foursquare (Badge Unlock)')
s
s.loc['youtube'] = s.loc['YouTube'] + s.loc['Youtube']
s
s = s.drop('YouTube')
s = s.drop('Youtube')
s
s.loc['iphone'] = s.loc['iPhone'] + s.loc['iPhone App'] + s.loc['iPhone app']
s
s = s.drop('iPhone')
s = s.drop('iPhone App')
s = s.drop('iPhone app')
s
f3,ax3=plt.subplots()
ax3.axis('equal')
s.plot(y=s.columns[0], kind='pie', labels=['' for x in range(len(s.index))], ax=ax3, title=s.index.name, fontsize=10)
ax3.legend(loc=3, labels=s.index,bbox_to_anchor=(-0.070,0))
ax3.set_ylabel('')
from os.path import join
pathname = join(target_folder, 'piechart.png')
f3.savefig(pathname)
print('piechart_image_path = %s' % pathname)