@@ -73,7 +73,7 @@ def read_csv(
7373 Examples
7474 --------
7575 >>> from pymove.utils.trajectories import read_csv
76- >>> move_df = read_csv('... geolife_sample.csv')
76+ >>> move_df = read_csv('geolife_sample.csv')
7777 >>> move_df.head()
7878 lat lon datetime id
7979 0 39.984094 116.319236 2008-10-23 05:53:05 1
@@ -109,9 +109,9 @@ def invert_dict(d: Dict) -> Dict:
109109 Examples
110110 --------
111111 >>> from pymove.utils.trajectories import invert_dict
112- >>> traj_dict = {'lat':39.984094 , 'lon':116.319236 }
112+ >>> traj_dict = {'a': 1 , 'b': 2 }
113113 >>> invert_dict(traj_dict)
114- {39.984094 : 'lat', 116.319236 : 'lon'} <class 'dict'>
114+ {1 : 'a, 2 : 'b}
115115 """
116116 return {v : k for k , v in d .items ()}
117117
@@ -143,9 +143,9 @@ def flatten_dict(
143143 Examples
144144 --------
145145 >>> from pymove.utils.trajectories import flatten_dict
146- >>> traj_dict = {'lat':39.984094 , 'lon':116.319236 }
146+ >>> d = {'a': 1 , 'b': {'c': 2, 'd': 3} }
147147 >>> flatten_dict(traj_dict, 'x')
148- {'x_lat ': 39.984094 , 'x_lon ': 116.319236} <class 'dict'>
148+ {'x_a ': 1 , 'x_b_c ': 2, 'x_b_d': 3}
149149 """
150150 if not isinstance (d , dict ):
151151 return {parent_key : d }
@@ -257,10 +257,10 @@ def shift(
257257 >>> array = [1,2,3,4,5,6,7]
258258 >>> print(shift(array, 1), type(shift(array, 1)))
259259 [0 1 2 3 4 5 6] <class 'numpy.ndarray'>
260- >>> print(shift(array, 2 ), type(shift(array, 2 )))
261- [0 0 1 2 3 4 5 ] <class 'numpy.ndarray '>
262- >>> print(shift(array, 3 ), type(shift(array, 3 )))
263- [0 0 0 1 2 3 4 ] <class 'numpy.ndarray'>
260+ >>> print(shift(array, 0 ), type(shift(array, 0 )))
261+ [1, 2, 3, 4, 5, 6, 7 ] <class 'list '>
262+ >>> print(shift(array, -1 ), type(shift(array, -1 )))
263+ [2 3 4 5 6 7 0 ] <class 'numpy.ndarray'>
264264 """
265265 result = np .empty_like (arr )
266266 if fill_value is None :
@@ -304,11 +304,10 @@ def fill_list_with_new_values(original_list: List, new_list_values: List):
304304 Example
305305 -------
306306 >>> from pymove.utils.trajectories import fill_list_with_new_values
307- >>> original_list = [4,3,2,1,0]
308- >>> new_list = [9,8,7,6,5]
309- >>> fill_list_with_new_values(original_list, new_list)
310- >>> print(original_list, type(original_list))
311- ['oveD'] <class 'numpy.ndarray'>[9, 8, 7, 6, 5] <class 'list'>
307+ >>> lt = [1, 2, 3, 4]
308+ >>> fill_list_with_new_values(lt, ['a','b'])
309+ >>> print(lt, type(lt))
310+ ['a', 'b', 3, 4] <class 'list'>
312311 """
313312 n = len (new_list_values )
314313 original_list [:n ] = new_list_values
@@ -331,12 +330,11 @@ def object_for_array(object_: Text) -> ndarray:
331330 Examples
332331 --------
333332 >>> from pymove.utils.trajectories import object_for_array
334- >>> print(object_for_array('lat'), type(object_for_array('lat')))
335- ['a'] <class 'numpy.ndarray'>
336- >>> print(object_for_array('move'), type(object_for_array('move')))
337- ['ov'] <class 'numpy.ndarray'>
338- >>> print(object_for_array('moveDf'), type(object_for_array('moveDf')))
339- ['oveD'] <class 'numpy.ndarray'>
333+ >>> list_str = '[1,2,3,4,5]'
334+ >>> object_for_array(list_str)
335+ array([1., 2., 3., 4., 5.], dtype=float32)
336+ >>> print(type(object_for_array(list_str)))
337+ <class 'numpy.ndarray'>
340338 """
341339 if object_ is None :
342340 return object_
@@ -364,7 +362,7 @@ def column_to_array(data: DataFrame, column: Text):
364362 Returns
365363 -------
366364 dataframe
367- Dataframe with the new column...
365+ Dataframe with the selected column converted to list
368366
369367 Example
370368 -------
0 commit comments