Skip to content

Commit d54e74c

Browse files
authored
TST: compatible with pandas 2.0 (#470)
1 parent bbc8331 commit d54e74c

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

examples/trackintel_basic_tutorial.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@
227227
"outputs": [],
228228
"source": [
229229
"# we concate sp and tpls to get the whole mobility trace\n",
230-
"trace = sp.append(tpls)\n",
230+
"trace = pd.concat([sp, tpls])\n",
231+
"\n",
231232
"# calculate the overall tracking coverage\n",
232233
"ti.analysis.tracking_quality.temporal_tracking_quality(trace, granularity='all')"
233234
]
@@ -332,7 +333,7 @@
332333
"name": "python",
333334
"nbconvert_exporter": "python",
334335
"pygments_lexer": "ipython3",
335-
"version": "3.8.12"
336+
"version": "3.10.9"
336337
},
337338
"vscode": {
338339
"interpreter": {

tests/preprocessing/test_triplegs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ def test_generate_trips_gap_detection(self):
226226
sep=";",
227227
index_col="id",
228228
parse_dates=[0, 1],
229-
infer_datetime_format=True,
230229
dayfirst=True,
231230
)
232231
sp_in["geom"] = Point(1, 1)
@@ -238,7 +237,6 @@ def test_generate_trips_gap_detection(self):
238237
sep=";",
239238
index_col="id",
240239
parse_dates=[0, 1],
241-
infer_datetime_format=True,
242240
dayfirst=True,
243241
)
244242
tpls_in["geom"] = LineString([[1, 1], [2, 2]])

tests/preprocessing/test_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ def test_list_column(self):
7878
agg_df = pd.DataFrame(agg)
7979
returned_df = _explode_agg("id", "c", orig_df, agg_df)
8080
solution_df = pd.DataFrame(orig)
81+
8182
assert_frame_equal(returned_df, solution_df)
8283

8384
def test_index_dtype_with_None(self):
8485
"""Test if dtype of index isn't changed with None values."""
85-
orig = [
86-
{"a": 1, "c": 0},
87-
]
86+
orig = [{"a": 1, "c": 0}]
8887
agg = [{"id": [0, 1], "c": 0}, {"id": [], "c": 1}]
8988
orig_df = pd.DataFrame(orig, columns=["a"])
9089
agg_df = pd.DataFrame(agg)
9190
returned_df = _explode_agg("id", "c", orig_df, agg_df)
9291
solution_df = pd.DataFrame(orig)
92+
9393
assert_frame_equal(returned_df, solution_df)
9494

9595

trackintel/preprocessing/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ def _explode_agg(column, agg, orig_df, agg_df):
107107
temp = agg_df.explode(column)
108108
temp = temp[temp[column].notna()]
109109
temp.index = temp[column]
110-
return orig_df.join(temp[agg], how="left")
110+
111+
return_df = orig_df.join(temp[agg], how="left")
112+
# ensure index dtype the same as input
113+
return_df.index = return_df.index.astype(orig_df.index.dtype)
114+
return return_df
111115

112116

113117
def angle_centroid_multipoints(geometry):

0 commit comments

Comments
 (0)