import pandas as pd
data = pd. read_csv( r'data-sample/TaxiData-Sample' , header = None )
data. columns = [ 'VehicleNum' , 'Stime' , 'Lng' , 'Lat' , 'OpenStatus' , 'Speed' ]
data
VehicleNum Stime Lng Lat OpenStatus Speed 0 22271 22:54:04 114.167000 22.718399 0 0 1 22271 18:26:26 114.190598 22.647800 0 4 2 22271 18:35:18 114.201401 22.649700 0 0 3 22271 16:02:46 114.233498 22.725901 0 24 4 22271 21:41:17 114.233597 22.720900 0 19 ... ... ... ... ... ... ... 1601302 23873 20:20:03 114.160149 22.606934 0 0 1601303 23873 20:15:13 114.164551 22.605118 1 48 1601304 23873 20:16:23 114.168015 22.606083 0 0 1601305 23873 20:16:43 114.168015 22.606083 0 0 1601306 23873 20:26:39 114.170647 22.604383 0 0
1601307 rows × 6 columns
data[ data[ 'VehicleNum' ] == 22271 ]
VehicleNum Stime Lng Lat OpenStatus Speed 0 22271 22:54:04 114.167000 22.718399 0 0 1 22271 18:26:26 114.190598 22.647800 0 4 2 22271 18:35:18 114.201401 22.649700 0 0 3 22271 16:02:46 114.233498 22.725901 0 24 4 22271 21:41:17 114.233597 22.720900 0 19 ... ... ... ... ... ... ... 1432 22271 11:31:09 114.279404 22.739000 0 0 1433 22271 11:33:09 114.279404 22.739000 0 0 1434 22271 10:43:56 114.279503 22.739000 0 0 1435 22271 10:51:48 114.279503 22.739201 0 0 1436 22271 00:07:41 114.282700 22.727800 0 23
1437 rows × 6 columns
data[ - ( data[ 'VehicleNum' ] == 22271 ] . head( 2 )
VehicleNum Stime Lng Lat OpenStatus Speed 1437 35807 01:53:46 113.809898 22.626801 0 0 1438 35807 01:43:46 113.813301 22.623600 0 0
data= data. sort_values( by= [ 'VehicleNum' , 'Stime' ] )
data
VehicleNum Stime Lng Lat OpenStatus Speed 39 22271 00:00:49 114.266502 22.728201 0 0 397 22271 00:01:48 114.266502 22.728201 0 0 1413 22271 00:02:47 114.266502 22.728201 0 0 244 22271 00:03:46 114.266502 22.728201 0 0 247 22271 00:04:45 114.268898 22.729500 0 11 ... ... ... ... ... ... ... 25320 36934 23:49:54 114.056702 22.595800 0 36 25831 36934 23:50:42 114.060303 22.603701 0 40 25485 36934 23:52:32 114.069199 22.614500 0 31 25749 36934 23:53:02 114.067398 22.618401 0 32 26464 36934 23:53:32 114.067299 22.621599 0 7
1601307 rows × 6 columns
data2= data. iloc[ 2460 : 2480 ]
data2
VehicleNum Stime Lng Lat OpenStatus Speed 1550423 22334 06:27:51 114.036018 22.519051 0 19 1549900 22334 06:28:11 114.035248 22.517817 0 25 1549352 22334 06:28:31 114.035149 22.517616 0 5 1550422 22334 06:28:51 114.034569 22.517967 0 0 1547256 22334 06:29:11 114.032349 22.518984 0 21 1547418 22334 06:29:31 114.031250 22.519550 0 22 1547419 22334 06:29:51 114.031250 22.519550 0 0 1547764 22334 06:30:11 114.031250 22.519550 0 0 1550417 22334 06:30:19 114.031250 22.519550 1 0 1547416 22334 06:30:39 114.030098 22.520317 1 18 1547252 22334 06:30:59 114.029480 22.521549 1 35 1548778 22334 06:31:19 114.030617 22.523132 1 35 1550084 22334 06:31:39 114.030983 22.523632 1 11 1548597 22334 06:31:59 114.030983 22.523632 1 0 1548598 22334 06:32:19 114.031265 22.524099 1 5 1547257 22334 06:32:39 114.032448 22.525850 1 40 1547422 22334 06:32:59 114.032501 22.525917 1 1 1549350 22334 06:33:19 114.032501 22.525917 1 0 1549351 22334 06:33:39 114.032730 22.526318 1 4 1550421 22334 06:33:59 114.033730 22.528099 1 40
data2[ 'OpenStatus' ] . shift( )
1550423 NaN
1549900 0.0
1549352 0.0
1550422 0.0
1547256 0.0
1547418 0.0
1547419 0.0
1547764 0.0
1550417 0.0
1547416 1.0
1547252 1.0
1548778 1.0
1550084 1.0
1548597 1.0
1548598 1.0
1547257 1.0
1547422 1.0
1549350 1.0
1549351 1.0
1550421 1.0
Name: OpenStatus, dtype: float64
data2[ 'OpenStatus1' ] = data2[ 'OpenStatus' ] . shift( )
<ipython-input-59-8e1c0ecd6a11>:2: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
data2['OpenStatus1']=data2['OpenStatus'].shift()
data2
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 1550423 22334 06:27:51 114.036018 22.519051 0 19 NaN 1549900 22334 06:28:11 114.035248 22.517817 0 25 0.0 1549352 22334 06:28:31 114.035149 22.517616 0 5 0.0 1550422 22334 06:28:51 114.034569 22.517967 0 0 0.0 1547256 22334 06:29:11 114.032349 22.518984 0 21 0.0 1547418 22334 06:29:31 114.031250 22.519550 0 22 0.0 1547419 22334 06:29:51 114.031250 22.519550 0 0 0.0 1547764 22334 06:30:11 114.031250 22.519550 0 0 0.0 1550417 22334 06:30:19 114.031250 22.519550 1 0 0.0 1547416 22334 06:30:39 114.030098 22.520317 1 18 1.0 1547252 22334 06:30:59 114.029480 22.521549 1 35 1.0 1548778 22334 06:31:19 114.030617 22.523132 1 35 1.0 1550084 22334 06:31:39 114.030983 22.523632 1 11 1.0 1548597 22334 06:31:59 114.030983 22.523632 1 0 1.0 1548598 22334 06:32:19 114.031265 22.524099 1 5 1.0 1547257 22334 06:32:39 114.032448 22.525850 1 40 1.0 1547422 22334 06:32:59 114.032501 22.525917 1 1 1.0 1549350 22334 06:33:19 114.032501 22.525917 1 0 1.0 1549351 22334 06:33:39 114.032730 22.526318 1 4 1.0 1550421 22334 06:33:59 114.033730 22.528099 1 40 1.0
data = data[ - ( ( data[ 'OpenStatus' ] . shift( - 1 ) == data[ 'OpenStatus' ] . shift( ) ) &
( data[ 'OpenStatus' ] . shift( - 1 ) != data[ 'OpenStatus' ] ) &
( data[ 'VehicleNum' ] . shift( - 1 ) == data[ 'VehicleNum' ] . shift( ) ) &
( data[ 'VehicleNum' ] . shift( - 1 ) == data[ 'VehicleNum' ] ) ) ]
data
VehicleNum Stime Lng Lat OpenStatus Speed 39 22271 00:00:49 114.266502 22.728201 0 0 397 22271 00:01:48 114.266502 22.728201 0 0 1413 22271 00:02:47 114.266502 22.728201 0 0 244 22271 00:03:46 114.266502 22.728201 0 0 247 22271 00:04:45 114.268898 22.729500 0 11 ... ... ... ... ... ... ... 25320 36934 23:49:54 114.056702 22.595800 0 36 25831 36934 23:50:42 114.060303 22.603701 0 40 25485 36934 23:52:32 114.069199 22.614500 0 31 25749 36934 23:53:02 114.067398 22.618401 0 32 26464 36934 23:53:32 114.067299 22.621599 0 7
1598866 rows × 6 columns
data[ 'OpenStatus1' ] = data[ 'OpenStatus' ] . shift( - 1 )
<ipython-input-72-6240087fbc74>:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
data['OpenStatus1']=data['OpenStatus'].shift(-1)
data
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 39 22271 00:00:49 114.266502 22.728201 0 0 0.0 397 22271 00:01:48 114.266502 22.728201 0 0 0.0 1413 22271 00:02:47 114.266502 22.728201 0 0 0.0 244 22271 00:03:46 114.266502 22.728201 0 0 0.0 247 22271 00:04:45 114.268898 22.729500 0 11 0.0 ... ... ... ... ... ... ... ... 25320 36934 23:49:54 114.056702 22.595800 0 36 0.0 25831 36934 23:50:42 114.060303 22.603701 0 40 0.0 25485 36934 23:52:32 114.069199 22.614500 0 31 0.0 25749 36934 23:53:02 114.067398 22.618401 0 32 0.0 26464 36934 23:53:32 114.067299 22.621599 0 7 NaN
1598866 rows × 7 columns
data[ 'Statuschange' ] = data[ 'OpenStatus1' ] - data[ 'OpenStatus' ]
<ipython-input-74-c1d32677d8c5>:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
data['Statuschange']=data['OpenStatus1']-data['OpenStatus']
data
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 Statuschange 39 22271 00:00:49 114.266502 22.728201 0 0 0.0 0.0 397 22271 00:01:48 114.266502 22.728201 0 0 0.0 0.0 1413 22271 00:02:47 114.266502 22.728201 0 0 0.0 0.0 244 22271 00:03:46 114.266502 22.728201 0 0 0.0 0.0 247 22271 00:04:45 114.268898 22.729500 0 11 0.0 0.0 ... ... ... ... ... ... ... ... ... 25320 36934 23:49:54 114.056702 22.595800 0 36 0.0 0.0 25831 36934 23:50:42 114.060303 22.603701 0 40 0.0 0.0 25485 36934 23:52:32 114.069199 22.614500 0 31 0.0 0.0 25749 36934 23:53:02 114.067398 22.618401 0 32 0.0 0.0 26464 36934 23:53:32 114.067299 22.621599 0 7 NaN NaN
1598866 rows × 8 columns
data. iloc[ 2920 : 2940 ]
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 Statuschange 1550238 22334 09:05:01 113.982353 22.553267 1 7 1.0 0.0 1546888 22334 09:05:21 113.981300 22.551933 1 16 1.0 0.0 1550586 22334 09:05:41 113.980217 22.551600 1 25 1.0 0.0 1546885 22334 09:06:01 113.978951 22.552549 1 29 1.0 0.0 1548246 22334 09:06:21 113.978821 22.552700 1 3 0.0 -1.0 1547752 22334 09:06:23 113.978821 22.552700 0 0 0.0 0.0 1547739 22334 09:06:43 113.978821 22.552700 0 0 0.0 0.0 1549506 22334 09:07:03 113.978821 22.552700 0 0 0.0 0.0 1550237 22334 09:07:23 113.979980 22.551916 0 20 0.0 0.0 1549326 22334 09:07:43 113.980568 22.551018 0 22 0.0 0.0 1548582 22334 09:08:03 113.980370 22.550800 0 5 0.0 0.0 1546886 22334 09:08:23 113.980370 22.550800 0 0 0.0 0.0 1546887 22334 09:08:43 113.980370 22.550800 0 0 0.0 0.0 1547393 22334 09:09:03 113.980370 22.550800 0 0 0.0 0.0 1547740 22334 09:09:23 113.980370 22.550800 0 0 0.0 0.0 1549874 22334 09:09:43 113.980034 22.550400 0 3 0.0 0.0 1547934 22334 09:10:03 113.980400 22.549667 0 11 0.0 0.0 1547394 22334 09:10:23 113.981667 22.548700 0 30 0.0 0.0 1548082 22334 09:10:43 113.983383 22.547417 0 37 0.0 0.0 1549128 22334 09:11:03 113.985199 22.546000 0 41 0.0 0.0
data. iloc[ 2840 : 2860 ]
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 Statuschange 1548646 22334 08:37:03 114.055931 22.538349 0 0 0.0 0.0 1550648 22334 08:37:45 114.057198 22.537832 0 0 0.0 0.0 1548466 22334 08:38:05 114.057198 22.537832 0 0 0.0 0.0 1547826 22334 08:38:16 114.057198 22.537832 0 0 0.0 0.0 1548648 22334 08:38:36 114.057198 22.537832 0 0 0.0 0.0 1548649 22334 08:38:56 114.057198 22.537832 0 0 0.0 0.0 1549017 22334 08:39:16 114.057419 22.537617 0 2 1.0 1.0 1550298 22334 08:39:20 114.057419 22.537617 1 0 1.0 0.0 1550299 22334 08:39:40 114.057419 22.537617 1 0 1.0 0.0 1548145 22334 08:40:00 114.056366 22.537600 1 4 1.0 0.0 1548461 22334 08:40:20 114.055763 22.537500 1 7 1.0 0.0 1550639 22334 08:40:40 114.052902 22.535633 1 71 1.0 0.0 1550460 22334 08:41:20 114.055031 22.534634 1 27 1.0 0.0 1549754 22334 08:42:00 114.054131 22.531282 1 27 1.0 0.0 1548139 22334 08:42:20 114.052231 22.531218 1 32 1.0 0.0 1547119 22334 08:42:40 114.048935 22.531601 1 39 1.0 0.0 1549380 22334 08:43:00 114.046364 22.531584 1 46 1.0 0.0 1547440 22334 08:43:20 114.043404 22.531384 1 55 1.0 0.0 1548608 22334 08:43:40 114.040535 22.531082 1 52 1.0 0.0 1548601 22334 08:44:00 114.037697 22.530916 1 47 1.0 0.0
data[ ( data[ 'Statuschange' ] == 1 ) | ( data[ 'Statuschange' ] == - 1 ) ]
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 Statuschange 136 22271 23:53:08 114.205704 22.720400 0 47 1.0 1.0 1548741 22334 00:00:52 114.111130 22.576750 1 13 0.0 -1.0 1548351 22334 00:07:44 114.080498 22.554182 0 11 1.0 1.0 1549620 22334 00:17:58 114.084915 22.540850 1 2 0.0 -1.0 1547182 22334 00:18:56 114.084915 22.540850 0 0 1.0 1.0 ... ... ... ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 1 15 0.0 -1.0 458104 36805 23:35:55 114.112968 22.549601 0 9 1.0 1.0 458416 36805 23:42:55 114.089500 22.538067 1 51 0.0 -1.0 455681 36805 23:46:12 114.091217 22.540768 0 0 1.0 1.0 453987 36805 23:53:33 114.120354 22.544300 1 0 0.0 -1.0
30242 rows × 8 columns
data[ ( ( data[ 'Statuschange' ] == 1 ) | ( data[ 'Statuschange' ] == - 1 ) ) & ( data[ 'VehicleNum' ] == data[ 'VehicleNum' ] . shift( - 1 ) ) ]
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 Statuschange 1548741 22334 00:00:52 114.111130 22.576750 1 13 0.0 -1.0 1548351 22334 00:07:44 114.080498 22.554182 0 11 1.0 1.0 1549620 22334 00:17:58 114.084915 22.540850 1 2 0.0 -1.0 1547182 22334 00:18:56 114.084915 22.540850 0 0 1.0 1.0 1547627 22334 00:44:47 114.056236 22.633383 1 3 0.0 -1.0 ... ... ... ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 1 15 0.0 -1.0 458104 36805 23:35:55 114.112968 22.549601 0 9 1.0 1.0 458416 36805 23:42:55 114.089500 22.538067 1 51 0.0 -1.0 455681 36805 23:46:12 114.091217 22.540768 0 0 1.0 1.0 453987 36805 23:53:33 114.120354 22.544300 1 0 0.0 -1.0
30016 rows × 8 columns
oddata= data[ ( ( data[ 'Statuschange' ] == 1 ) | ( data[ 'Statuschange' ] == - 1 ) ) & ( data[ 'VehicleNum' ] == data[ 'VehicleNum' ] . shift( - 1 ) ) ]
oddata
VehicleNum Stime Lng Lat OpenStatus Speed OpenStatus1 Statuschange 1548741 22334 00:00:52 114.111130 22.576750 1 13 0.0 -1.0 1548351 22334 00:07:44 114.080498 22.554182 0 11 1.0 1.0 1549620 22334 00:17:58 114.084915 22.540850 1 2 0.0 -1.0 1547182 22334 00:18:56 114.084915 22.540850 0 0 1.0 1.0 1547627 22334 00:44:47 114.056236 22.633383 1 3 0.0 -1.0 ... ... ... ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 1 15 0.0 -1.0 458104 36805 23:35:55 114.112968 22.549601 0 9 1.0 1.0 458416 36805 23:42:55 114.089500 22.538067 1 51 0.0 -1.0 455681 36805 23:46:12 114.091217 22.540768 0 0 1.0 1.0 453987 36805 23:53:33 114.120354 22.544300 1 0 0.0 -1.0
30016 rows × 8 columns
oddata[ [ 'VehicleNum' , 'Stime' , 'Lng' , 'Lat' , 'Statuschange' ] ]
VehicleNum Stime Lng Lat Statuschange 1548741 22334 00:00:52 114.111130 22.576750 -1.0 1548351 22334 00:07:44 114.080498 22.554182 1.0 1549620 22334 00:17:58 114.084915 22.540850 -1.0 1547182 22334 00:18:56 114.084915 22.540850 1.0 1547627 22334 00:44:47 114.056236 22.633383 -1.0 ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 -1.0 458104 36805 23:35:55 114.112968 22.549601 1.0 458416 36805 23:42:55 114.089500 22.538067 -1.0 455681 36805 23:46:12 114.091217 22.540768 1.0 453987 36805 23:53:33 114.120354 22.544300 -1.0
30016 rows × 5 columns
oddata= oddata[ [ 'VehicleNum' , 'Stime' , 'Lng' , 'Lat' , 'Statuschange' ] ]
oddata
VehicleNum Stime Lng Lat Statuschange 1548741 22334 00:00:52 114.111130 22.576750 -1.0 1548351 22334 00:07:44 114.080498 22.554182 1.0 1549620 22334 00:17:58 114.084915 22.540850 -1.0 1547182 22334 00:18:56 114.084915 22.540850 1.0 1547627 22334 00:44:47 114.056236 22.633383 -1.0 ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 -1.0 458104 36805 23:35:55 114.112968 22.549601 1.0 458416 36805 23:42:55 114.089500 22.538067 -1.0 455681 36805 23:46:12 114.091217 22.540768 1.0 453987 36805 23:53:33 114.120354 22.544300 -1.0
30016 rows × 5 columns
oddata. columns= [ 'VehicleNum' , 'Stime' , 'SLng' , 'SLat' , 'Statuschange' ]
oddata
VehicleNum Stime SLng SLat Statuschange 1548741 22334 00:00:52 114.111130 22.576750 -1.0 1548351 22334 00:07:44 114.080498 22.554182 1.0 1549620 22334 00:17:58 114.084915 22.540850 -1.0 1547182 22334 00:18:56 114.084915 22.540850 1.0 1547627 22334 00:44:47 114.056236 22.633383 -1.0 ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 -1.0 458104 36805 23:35:55 114.112968 22.549601 1.0 458416 36805 23:42:55 114.089500 22.538067 -1.0 455681 36805 23:46:12 114.091217 22.540768 1.0 453987 36805 23:53:33 114.120354 22.544300 -1.0
30016 rows × 5 columns
oddata[ 'Elng' ] = oddata[ 'SLng' ] . shift( - 1 )
<ipython-input-110-74375a3c7844>:2: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
oddata['Elng']=oddata['SLng'].shift(-1)
oddata[ 'ELat' ] = oddata[ 'SLat' ] . shift( - 1 )
oddata[ 'Etime' ] = oddata[ 'Stime' ] . shift( - 1 )
<ipython-input-111-7dbbfabccb1e>:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
oddata['ELat']=oddata['SLat'].shift(-1)
oddata
VehicleNum Stime SLng SLat Statuschange Elng ELat Etime 1548741 22334 00:00:52 114.111130 22.576750 -1.0 114.080498 22.554182 00:07:44 1548351 22334 00:07:44 114.080498 22.554182 1.0 114.084915 22.540850 00:17:58 1549620 22334 00:17:58 114.084915 22.540850 -1.0 114.084915 22.540850 00:18:56 1547182 22334 00:18:56 114.084915 22.540850 1.0 114.056236 22.633383 00:44:47 1547627 22334 00:44:47 114.056236 22.633383 -1.0 114.091637 22.543200 02:38:35 ... ... ... ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 -1.0 114.112968 22.549601 23:35:55 458104 36805 23:35:55 114.112968 22.549601 1.0 114.089500 22.538067 23:42:55 458416 36805 23:42:55 114.089500 22.538067 -1.0 114.091217 22.540768 23:46:12 455681 36805 23:46:12 114.091217 22.540768 1.0 114.120354 22.544300 23:53:33 453987 36805 23:53:33 114.120354 22.544300 -1.0 NaN NaN NaN
30016 rows × 8 columns
oddata[ oddata[ 'Statuschange' ] == 1 ]
VehicleNum Stime SLng SLat Statuschange Elng ELat Etime 1548351 22334 00:07:44 114.080498 22.554182 1.0 114.084915 22.540850 00:17:58 1547182 22334 00:18:56 114.084915 22.540850 1.0 114.056236 22.633383 00:44:47 1547511 22334 02:38:35 114.091637 22.543200 1.0 114.093498 22.554382 02:46:52 1547789 22334 03:58:46 114.038818 22.553232 1.0 114.052299 22.604366 04:13:57 1547764 22334 06:30:11 114.031250 22.519550 1.0 114.067886 22.521299 06:41:19 ... ... ... ... ... ... ... ... ... 454832 36805 22:49:01 114.114365 22.550632 1.0 114.115753 22.557550 22:50:30 456900 36805 22:51:55 114.115402 22.558083 1.0 114.118713 22.547882 23:03:03 453986 36805 23:03:42 114.118484 22.547867 1.0 114.133530 22.617550 23:20:04 458104 36805 23:35:55 114.112968 22.549601 1.0 114.089500 22.538067 23:42:55 455681 36805 23:46:12 114.091217 22.540768 1.0 114.120354 22.544300 23:53:33
15022 rows × 8 columns
oddata[ ( oddata[ 'Statuschange' ] == 1 ) & ( oddata[ 'VehicleNum' ] == oddata[ 'VehicleNum' ] . shift( - 1 ) ) ]
VehicleNum Stime SLng SLat Statuschange Elng ELat Etime 1548351 22334 00:07:44 114.080498 22.554182 1.0 114.084915 22.540850 00:17:58 1547182 22334 00:18:56 114.084915 22.540850 1.0 114.056236 22.633383 00:44:47 1547511 22334 02:38:35 114.091637 22.543200 1.0 114.093498 22.554382 02:46:52 1547789 22334 03:58:46 114.038818 22.553232 1.0 114.052299 22.604366 04:13:57 1547764 22334 06:30:11 114.031250 22.519550 1.0 114.067886 22.521299 06:41:19 ... ... ... ... ... ... ... ... ... 454832 36805 22:49:01 114.114365 22.550632 1.0 114.115753 22.557550 22:50:30 456900 36805 22:51:55 114.115402 22.558083 1.0 114.118713 22.547882 23:03:03 453986 36805 23:03:42 114.118484 22.547867 1.0 114.133530 22.617550 23:20:04 458104 36805 23:35:55 114.112968 22.549601 1.0 114.089500 22.538067 23:42:55 455681 36805 23:46:12 114.091217 22.540768 1.0 114.120354 22.544300 23:53:33
14818 rows × 8 columns
oddata. drop( 'Statuschange' , axis= 1 )
VehicleNum Stime SLng SLat Elng ELat Etime 1548741 22334 00:00:52 114.111130 22.576750 114.080498 22.554182 00:07:44 1548351 22334 00:07:44 114.080498 22.554182 114.084915 22.540850 00:17:58 1549620 22334 00:17:58 114.084915 22.540850 114.084915 22.540850 00:18:56 1547182 22334 00:18:56 114.084915 22.540850 114.056236 22.633383 00:44:47 1547627 22334 00:44:47 114.056236 22.633383 114.091637 22.543200 02:38:35 ... ... ... ... ... ... ... ... 459073 36805 23:20:04 114.133530 22.617550 114.112968 22.549601 23:35:55 458104 36805 23:35:55 114.112968 22.549601 114.089500 22.538067 23:42:55 458416 36805 23:42:55 114.089500 22.538067 114.091217 22.540768 23:46:12 455681 36805 23:46:12 114.091217 22.540768 114.120354 22.544300 23:53:33 453987 36805 23:53:33 114.120354 22.544300 NaN NaN NaN
30016 rows × 7 columns
oddate= oddata[ ( oddata[ 'Statuschange' ] == 1 ) & ( oddata[ 'VehicleNum' ] == oddata[ 'VehicleNum' ] . shift( - 1 ) ) ] . drop( 'Statuschange' , axis= 1 )
oddate
VehicleNum Stime SLng SLat Elng ELat Etime 1548351 22334 00:07:44 114.080498 22.554182 114.084915 22.540850 00:17:58 1547182 22334 00:18:56 114.084915 22.540850 114.056236 22.633383 00:44:47 1547511 22334 02:38:35 114.091637 22.543200 114.093498 22.554382 02:46:52 1547789 22334 03:58:46 114.038818 22.553232 114.052299 22.604366 04:13:57 1547764 22334 06:30:11 114.031250 22.519550 114.067886 22.521299 06:41:19 ... ... ... ... ... ... ... ... 454832 36805 22:49:01 114.114365 22.550632 114.115753 22.557550 22:50:30 456900 36805 22:51:55 114.115402 22.558083 114.118713 22.547882 23:03:03 453986 36805 23:03:42 114.118484 22.547867 114.133530 22.617550 23:20:04 458104 36805 23:35:55 114.112968 22.549601 114.089500 22.538067 23:42:55 455681 36805 23:46:12 114.091217 22.540768 114.120354 22.544300 23:53:33
14818 rows × 7 columns
oddate. to_csv( r'oddate.csv' , index= None , encoding= 'utf-8_sig' )