In [103]:
In [103]: for ship in dfContainer.userid.unique:
...: print(ship)
...:
Traceback (most recent call last):
File "<ipython-input-103-36f0b2aedf8a>", line 1, in <module>
for ship in dfContainer.userid.unique:
NameError: name 'dfContainer' is not defined
In [104]:
In [104]: for ship in dfContainer1.userid.unique:
...: print(ship)
...:
...:
...:
Traceback (most recent call last):
File "<ipython-input-104-3024beb65c59>", line 1, in <module>
for ship in dfContainer1.userid.unique:
TypeError: 'method' object is not iterable
In [105]:
In [105]: for ship in dfContainer1.userid.unique():
...: print(ship)
...:
636092159
477639500
477464400
563258000
477815200
563758000
477752400
636016277
477655800
636015130
477765800
563079000
477832300
477947600
477463500
477311500
477464500
477004700
477311600
477077700
477947700
636091765
636015467
477744200
428042000
355384000
563267000
566858000
477639300
538003742
422032200
636091835
477738900
413966000
412746000
477765900
477004600
477077800
477738700
428041000
477001700
477752300
412658000
636091766
477319300
477463400
538004099
413761000
413965000
412713000
255805598
477738800
477748400
636091746
636015131
412750000
636015503
477832200
636091714
412633000
538004094
412714000
In [106]: dfContainer5[dfContainer5.userid == 413965000]
Out[106]:
Empty DataFrame
Columns: [unixtime, dest, imo, ship_type, userid, draught, msgType, dRatio]
Index: []
In [107]: dfContainer5[dfContainer5.userid == 413965000].head()
Out[107]:
Empty DataFrame
Columns: [unixtime, dest, imo, ship_type, userid, draught, msgType, dRatio]
Index: []
In [108]: dfContainer5[dfContainer5.userid == 636015503].head()
Out[108]:
unixtime dest imo ... draught msgType dRatio
2504 1404389226 FELIXSTOWE 9484522 ... 92 5 0.730159
2505 1404389226 FELIXSTOWE 9484522 ... 92 5 0.730159
[2 rows x 8 columns]
In [109]: dfContainer5[dfContainer5.userid == 636092159].head()
Out[109]:
unixtime dest imo ... draught msgType dRatio
84 1399075266 CAUCEDO.DO 9477610 ... 113 5 0.896825
85 1399075266 CAUCEDO.DO 9477610 ... 113 5 0.896825
302 1399486828 ROTTERDAM 9477610 ... 127 5 1.007937
303 1399486828 ROTTERDAM 9477610 ... 127 5 1.007937
340 1399546948 ROTTERDAM 9477610 ... 127 5 1.007937
[5 rows x 8 columns]
In [110]: dfContainer5[dfContainer5.userid == 6360].head()
Out[110]:
Empty DataFrame
Columns: [unixtime, dest, imo, ship_type, userid, draught, msgType, dRatio]
Index: []
In [111]: dfContainer5.userid.value_counts()
Out[111]:
563267000 562
477752400 294
477947600 286
477311500 283
477001700 272
636091746 270
563758000 262
566858000 259
477464400 248
477765800 246
636015131 233
477463400 224
477004700 222
477947700 218
477464500 214
477463500 211
477311600 201
477832300 193
477077700 193
563079000 177
477319300 176
477744200 150
477077800 148
563258000 97
255805598 76
636091714 68
477639500 62
477639300 58
477748400 54
636091766 43
636091765 41
477815200 38
538003742 34
636015130 33
538004094 32
636092159 30
355384000 25
477765900 16
538004099 11
477004600 10
477738900 6
477752300 5
428042000 5
636091835 3
477738700 3
422032200 3
636016277 2
477655800 2
636015503 2
428041000 1
412633000 1
412658000 1
477738800 1
Name: userid, dtype: int64
In [112]: dfContainer5.userid.value_counts()
Out[112]:
563267000 562
477752400 294
477947600 286
477311500 283
477001700 272
636091746 270
563758000 262
566858000 259
477464400 248
477765800 246
636015131 233
477463400 224
477004700 222
477947700 218
477464500 214
477463500 211
477311600 201
477832300 193
477077700 193
563079000 177
477319300 176
477744200 150
477077800 148
563258000 97
255805598 76
636091714 68
477639500 62
477639300 58
477748400 54
636091766 43
636091765 41
477815200 38
538003742 34
636015130 33
538004094 32
636092159 30
355384000 25
477765900 16
538004099 11
477004600 10
477738900 6
477752300 5
428042000 5
636091835 3
477738700 3
422032200 3
636016277 2
477655800 2
636015503 2
428041000 1
412633000 1
412658000 1
477738800 1
Name: userid, dtype: int64
In [113]: dfContainer5.userid.value_counts().head(10)
Out[113]:
563267000 562
477752400 294
477947600 286
477311500 283
477001700 272
636091746 270
563758000 262
566858000 259
477464400 248
477765800 246
Name: userid, dtype: int64
In [114]: dfContainer5[dfContainer5.userid == 563267000].head()
Out[114]:
unixtime dest imo ... draught msgType dRatio
568 1400117773 AUBNE 9628336 ... 100 5 0.787402
615 1400253135 AUBNE 9628336 ... 99 5 0.779528
616 1400253135 AUBNE 9628336 ... 99 5 0.779528
656 1400287022 AUBNE 9628336 ... 99 5 0.779528
657 1400287023 AUBNE 9628336 ... 99 5 0.779528
[5 rows x 8 columns]
In [115]: dfContainer5[dfContainer5.userid == 563267000].draught
Out[115]:
568 100
615 99
616 99
656 99
657 99
658 99
674 99
712 99
714 99
715 99
728 99
756 99
757 99
758 99
759 99
806 99
821 99
822 99
829 99
830 99
831 99
832 99
836 99
898 95
916 95
925 95
930 95
931 95
949 95
950 95
...
5336 97
5337 97
5338 97
5339 97
5340 97
5341 97
5343 97
5344 97
5345 97
5352 97
5360 97
5376 97
5377 97
5379 97
5380 97
5381 97
5390 97
5393 97
5394 97
5421 97
5422 97
5467 97
5519 100
5531 100
5532 100
5566 100
5581 100
5648 100
5649 100
5704 100
Name: draught, Length: 562, dtype: int64
In [116]: max(dfContainer5[dfContainer5.userid == 563267000].draught)
Out[116]: 110
In [117]: runfile('/Users/havard/Desktop/Master/Master-Code/master.py', wdir='/Users/havard/Desktop/Master/Master-Code')
Reloaded modules: ais, ais_Plotting, db, locationCheck, readCSV, machineLearning
Traceback (most recent call last):
File "<ipython-input-117-abfebb621dbf>", line 1, in <module>
runfile('/Users/havard/Desktop/Master/Master-Code/master.py', wdir='/Users/havard/Desktop/Master/Master-Code')
File "/Users/havard/anaconda3/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "/Users/havard/anaconda3/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/havard/Desktop/Master/Master-Code/master.py", line 167, in <module>
d = max(dfContaier5[dfContainer5.userid == ship].draught)
NameError: name 'dfContaier5' is not defined
In [118]:
In [118]: runfile('/Users/havard/Desktop/Master/Master-Code/master.py', wdir='/Users/havard/Desktop/Master/Master-Code')
Reloaded modules: ais, ais_Plotting, db, locationCheck, readCSV, machineLearning
Traceback (most recent call last):
File "<ipython-input-118-abfebb621dbf>", line 1, in <module>
runfile('/Users/havard/Desktop/Master/Master-Code/master.py', wdir='/Users/havard/Desktop/Master/Master-Code')
File "/Users/havard/anaconda3/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "/Users/havard/anaconda3/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/havard/Desktop/Master/Master-Code/master.py", line 167, in <module>
d = max(dfContainer5[dfContainer5.userid == ship].draught)
ValueError: max() arg is an empty sequence
In [119]:
In [119]: dfContainer5[dfContainer5.userid == 563267000].draught
Out[119]:
568 100
615 99
616 99
656 99
657 99
658 99
674 99
712 99
714 99
715 99
728 99
756 99
757 99
758 99
759 99
806 99
821 99
822 99
829 99
830 99
831 99
832 99
836 99
898 95
916 95
925 95
930 95
931 95
949 95
950 95
...
5336 97
5337 97
5338 97
5339 97
5340 97
5341 97
5343 97
5344 97
5345 97
5352 97
5360 97
5376 97
5377 97
5379 97
5380 97
5381 97
5390 97
5393 97
5394 97
5421 97
5422 97
5467 97
5519 100
5531 100
5532 100
5566 100
5581 100
5648 100
5649 100
5704 100
Name: draught, Length: 562, dtype: int64
In [120]: dfContainer5[dfContainer5.userid == 563267000].draught[0]
Traceback (most recent call last):
File "<ipython-input-120-93cb535b23fe>", line 1, in <module>
dfContainer5[dfContainer5.userid == 563267000].draught[0]
File "/Users/havard/anaconda3/lib/python3.6/site-packages/pandas/core/series.py", line 868, in __getitem__
result = self.index.get_value(self, key)
File "/Users/havard/anaconda3/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 4320, in get_value
tz=getattr(series.dtype, 'tz', None))
File "pandas/_libs/index.pyx", line 81, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 89, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 987, in pandas._libs.hashtable.Int64HashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 993, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 0
In [121]:
In [121]: dfContainer5[dfContainer5.userid == 563267000].draught.head(0)
Out[121]: Series([], Name: draught, dtype: int64)
In [122]: dfContainer5[dfContainer5.userid == 563267000].draught.head(1)
Out[122]:
568 100
Name: draught, dtype: int64
In [123]: dfContainer5[dfContainer5.userid == 563267000].draught.head(1).value()
Traceback (most recent call last):
File "<ipython-input-123-9dcdb67e5087>", line 1, in <module>
dfContainer5[dfContainer5.userid == 563267000].draught.head(1).value()
File "/Users/havard/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py", line 5057, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'value'
In [124]:
In [124]: a = dfContainer5[dfContainer5.userid == 563267000].draught.head(1)
In [125]: a = dfContainer5[dfContainer5.userid == 563267000].draught.head(1)[0]