In [4]:
%matplotlib inline

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt 
import seaborn as sns

In [5]:
df = pd.read_csv("data/1.32.csv")

Test: Axes' Labels


In [6]:
playerscount = df["playerId"].nunique()
playerscount

gameSessionCount = df["playerId"].nunique()
print 'gameSessionCount={0}'.format(gameSessionCount)


studiedEvent = "craft"

percentageBarGraphMode = True
barGraphMode = True
percentageDefaultGraphMode = True
defaultGraphMode = True



columnName = studiedEvent+"s"
graphLabel = columnName

studiedEventCount = df[df["type"]==studiedEvent]["id"].count()
print '#{0}={1}'.format(studiedEvent,studiedEventCount)
mean = studiedEventCount / float(gameSessionCount)
print 'mean={0}'.format(mean)

positiveGameSessions = df[df["type"]==studiedEvent]["playerId"].value_counts()

positiveGameSessionCount = positiveGameSessions.count()
positiveGameSessionCountTable = pd.DataFrame({columnName: positiveGameSessions.values})

ax = positiveGameSessionCountTable.plot()
plt.xlabel("game sessions (%)")
plt.ylabel(graphLabel)
plt.legend('')

xvals = ax.get_xticks()
yvals = ax.get_yticks()
#percentage on y axis
#ax.set_yticklabels(['{:3.2f}%'.format(x*100/studiedEventCount) for x in vals])
#percentage on x axis
ax.set_xticklabels(['{:3.2f}%'.format((x*100)/(positiveGameSessionCount-1)) for x in xvals])

ax = positiveGameSessionCountTable.plot()
plt.xlabel("game sessions")
plt.ylabel(graphLabel)
plt.legend('')

print '#positiveGameSession={0}'.format(positiveGameSessionCount)


gameSessionCount=184
#craft=70
mean=0.380434782609
#positiveGameSession=21