In [4]:
import pandas
import csv, sys
csv.field_size_limit(sys.maxint)
import os

In [1]:
folder = '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/'

In [2]:
files = !ls /Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/*.csv

In [3]:
files


Out[3]:
['/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_bias_mistake_0.0.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_bias_mistake_0.01.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_bias_mistake_0.0625.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_bias_mistake_0.125.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_stingy_mistake_0.0.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_stingy_mistake_0.01.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_stingy_mistake_0.0625.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_stingy_mistake_0.125.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_uniform_mistake_0.0.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_uniform_mistake_0.01.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_uniform_mistake_0.0625.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_1_scheme_uniform_mistake_0.125.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_bias_mistake_0.0.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_bias_mistake_0.01.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_bias_mistake_0.0625.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_bias_mistake_0.125.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_stingy_mistake_0.0.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_stingy_mistake_0.01.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_stingy_mistake_0.0625.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_stingy_mistake_0.125.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_uniform_mistake_0.0.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_uniform_mistake_0.01.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_uniform_mistake_0.0625.csv',
 '/Users/garcia/Dropbox/simulationResults/repeatedgameswithmistakes/fourth_trial_with_measures/tr_4_time_game_2_scheme_uniform_mistake_0.125.csv']

In [23]:
df = pandas.read_csv(files[0])

In [24]:
df


Out[24]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 10001 entries, 0 to 10000
Data columns:
timeStep       10001  non-null values
totalPayoff    10001  non-null values
population     10001  non-null values
Leniency       19  non-null values
Forgiveness    10  non-null values
TotalCoop      10001  non-null values
dtypes: float64(4), int64(1), object(1)

In [42]:
print "Forgiveness"
print "Minimum value: " + str(df['Forgiveness'].min())
print "Mean value: " + str(df['Forgiveness'].mean())
print "Median value : " + str(df['Forgiveness'].median())
print "Maximum value: " + str(df['Forgiveness'].max())
print "Non-null values: " + str(df['Forgiveness'].count())
print "Number of records: " + str(size(df['Forgiveness']))


Forgiveness
Minimum value: 0.0
Minimum value: 0.283333333333
Median value : 0.0
Maximum value: 1.0
Non-null values: 10
Number of records: 10001

In [85]:
df['Forgiveness'].hist()
not_null_pc = int(df['Forgiveness'].count())
cadena_titulo = 'Forgiveness per gen \n  mean:' + str(df['Forgiveness'].mean()) + '\n data points used: ' + str(not_null_pc)
plt.title(cadena_titulo)


Out[85]:
<matplotlib.text.Text at 0x9d9ba90>

In [55]:
df['averagePayoff'] = df['totalPayoff']/200.0
df['averagePayoff'].hist(color='r')
plt.title('Average payoff distribution')


Out[55]:
<matplotlib.text.Text at 0x8511390>

In [ ]: