In [25]:
import pandas
import numpy

In [26]:
data = pandas.read_csv("logfile2.txt")
data = data.replace(to_replace="None", value=np.nan)

In [82]:
data=data.astype(float)

In [100]:
data


Out[100]:
leftposx leftposy rightposx rightposy ballx bally leftvely rightvely ballvelx ballvely action reward framei i terminate
0 NaN NaN 139 62 0 0 NaN NaN NaN NaN 1 0 51 51 0
1 NaN NaN 139 62 0 0 NaN 0 0 0 1 0 52 52 0
2 NaN NaN 139 62 0 0 NaN 0 0 0 1 0 53 53 0
3 NaN NaN 139 62 0 0 NaN 0 0 0 1 0 54 54 0
4 NaN NaN 139 62 0 0 NaN 0 0 0 1 0 55 55 0
5 NaN NaN 139 62 0 0 NaN 0 0 0 1 0 56 56 0
6 NaN NaN 139 62 0 0 NaN 0 0 0 1 0 57 57 0
7 NaN NaN 139 62 0 0 NaN 0 0 0 1 0 58 58 0
8 19 81 139 62 81 78 NaN 0 81 78 1 0 59 59 0
9 19 81 139 62 81 78 0 0 0 0 1 0 60 60 0
10 19 81 139 62 82 77 0 0 1 -1 1 0 61 61 0
11 19 83 139 62 83 76 2 0 1 -1 1 0 62 62 0
12 19 83 139 62 84 75 0 0 1 -1 1 0 63 63 0
13 19 85 139 62 85 74 2 0 1 -1 1 0 64 64 0
14 19 85 139 62 86 73 0 0 1 -1 1 0 65 65 0
15 19 87 139 62 87 72 2 0 1 -1 1 0 66 66 0
16 19 87 139 62 88 71 0 0 1 -1 1 0 67 67 0
17 19 89 139 62 89 70 2 0 1 -1 1 0 68 68 0
18 19 89 139 62 90 69 0 0 1 -1 7 0 69 69 0
19 19 91 139 62 91 68 2 0 1 -1 1 0 70 70 0
20 19 91 139 62 92 67 0 0 1 -1 1 0 71 71 0
21 19 93 139 62 93 66 2 0 1 -1 1 0 72 72 0
22 19 93 139 64 94 65 0 2 1 -1 1 0 73 73 0
23 19 95 139 64 95 64 2 0 1 -1 1 0 74 74 0
24 19 95 139 64 96 63 0 0 1 -1 1 0 75 75 0
25 19 97 139 64 97 62 2 0 1 -1 1 0 76 76 0
26 19 97 139 66 98 61 0 2 1 -1 1 0 77 77 0
27 19 99 139 66 99 60 2 0 1 -1 1 0 78 78 0
28 19 99 139 66 100 59 0 0 1 -1 7 0 79 79 0
29 19 101 139 66 101 58 2 0 1 -1 7 0 80 80 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
9084 19 139 139 100 141 41 -2 0 -1 4 1 0 369 9135 0
9085 19 139 139 100 140 45 0 0 -1 4 1 0 370 9136 0
9086 19 137 139 100 139 49 -2 0 -1 4 1 0 371 9137 0
9087 19 137 139 100 138 53 0 0 -1 4 1 0 372 9138 0
9088 19 135 139 100 137 57 -2 0 -1 4 1 0 373 9139 0
9089 19 135 139 100 136 61 0 0 -1 4 3 0 374 9140 0
9090 19 133 139 100 135 65 -2 0 -1 4 1 0 375 9141 0
9091 19 133 139 96 134 69 0 -4 -1 4 1 0 376 9142 0
9092 19 131 139 96 133 73 -2 0 -1 4 1 0 377 9143 0
9093 19 131 139 96 132 77 0 0 -1 4 3 0 378 9144 0
9094 19 129 139 96 131 81 -2 0 -1 4 1 0 379 9145 0
9095 19 129 139 92 130 85 0 -4 -1 4 1 0 380 9146 0
9096 19 127 139 92 129 89 -2 0 -1 4 1 0 381 9147 0
9097 19 127 139 90 128 93 0 -2 -1 4 1 0 382 9148 0
9098 19 125 139 90 127 97 -2 0 -1 4 1 0 383 9149 0
9099 19 125 139 88 126 101 0 -2 -1 4 1 0 384 9150 0
9100 19 123 139 88 125 105 -2 0 -1 4 1 0 385 9151 0
9101 19 123 139 88 124 109 0 0 -1 4 7 0 386 9152 0
9102 19 121 139 88 123 113 -2 0 -1 4 1 0 387 9153 0
9103 19 121 139 88 122 117 0 0 -1 4 1 0 388 9154 0
9104 19 119 139 92 121 121 -2 4 -1 4 1 0 389 9155 0
9105 19 119 139 92 120 125 0 0 -1 4 1 0 390 9156 0
9106 19 117 139 92 118 130 -2 0 -2 5 1 0 391 9157 0
9107 19 117 139 92 118 130 0 0 0 0 1 0 392 9158 0
9108 19 115 139 94 116 137 -2 2 -2 7 1 0 393 9159 0
9109 19 115 139 94 116 137 0 0 0 0 1 0 394 9160 0
9110 19 113 139 94 114 145 -2 0 -2 8 7 0 395 9161 0
9111 19 113 139 94 114 145 0 0 0 0 1 0 396 9162 0
9112 19 111 139 94 112 153 -2 0 -2 8 1 0 397 9163 0
9113 19 111 139 94 111 157 0 0 -1 4 1 0 398 9164 0

9114 rows × 15 columns


In [ ]:


In [ ]:


In [99]:
%pylab gtk
#import pylab
test=np.array(data2['ballvelx'][:1000].values)


data2=data.dropna()
pylab.plot(data2['i'][:1000],data2['bally'][:1000],'o')
pylab.figure()
pylab.plot(data2['i'][:1000],np.sqrt(np.array(data2['ballvely'][:1000])**2 +np.array(data2['ballvelx'][:1000])**2) ,'o')
pylab.ylim([0,10])


pylab.figure()
pylab.plot(data2['i'][1000:3000],np.abs(np.array(data2['ballvely'][1000:3000])) ,'o', color='r')
pylab.ylim([0,10])
pylab.figure()
pylab.plot(data2['i'][:1000],np.abs(np.array(data2['ballvelx'][:1000])) ,'o', color='g')
pylab.ylim([0,10])


/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk.py:250: Warning: Source ID 22920 was not found when attempting to remove it
  gobject.source_remove(self._idle_event_id)
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk.py:250: Warning: Source ID 22923 was not found when attempting to remove it
  gobject.source_remove(self._idle_event_id)
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk.py:250: Warning: Source ID 22925 was not found when attempting to remove it
  gobject.source_remove(self._idle_event_id)
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk.py:250: Warning: Source ID 22927 was not found when attempting to remove it
  gobject.source_remove(self._idle_event_id)
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['test']
`%matplotlib` prevents importing * from pylab and numpy
Out[99]:
(0, 10)

In [56]:
print data2[data2['reward'] == 1].index.tolist()
print np.array(data2[["i"]])[1987]
print data2[data2['reward'] == -1].index.tolist()

print data[["ballx"]].max()
print data[["ballx"]].min()
print data[["bally"]].max()
print data[["bally"]].min()


[1987, 2440, 2891, 3303, 5173, 8266]
[2179]
[400, 729, 1347, 1796, 2247, 2700, 3675, 4004, 4452, 4842, 4982, 5433, 5685, 5825, 6213, 6729, 6988, 7240, 8072, 8715]
ballx    157
dtype: int64
ballx    0
dtype: int64
bally    159
dtype: int64
bally    0
dtype: int64

In [ ]: