Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/trackintel_basic_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@
"outputs": [],
"source": [
"# we concate sp and tpls to get the whole mobility trace\n",
"trace = sp.append(tpls)\n",
"trace = pd.concat([sp, tpls])\n",
"\n",
"# calculate the overall tracking coverage\n",
"ti.analysis.tracking_quality.temporal_tracking_quality(trace, granularity='all')"
]
Expand Down Expand Up @@ -332,7 +333,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.10.9"
},
"vscode": {
"interpreter": {
Expand Down
2 changes: 0 additions & 2 deletions tests/preprocessing/test_triplegs.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def test_generate_trips_gap_detection(self):
sep=";",
index_col="id",
parse_dates=[0, 1],
infer_datetime_format=True,
dayfirst=True,
)
sp_in["geom"] = Point(1, 1)
Expand All @@ -238,7 +237,6 @@ def test_generate_trips_gap_detection(self):
sep=";",
index_col="id",
parse_dates=[0, 1],
infer_datetime_format=True,
dayfirst=True,
)
tpls_in["geom"] = LineString([[1, 1], [2, 2]])
Expand Down
6 changes: 3 additions & 3 deletions tests/preprocessing/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ def test_list_column(self):
agg_df = pd.DataFrame(agg)
returned_df = _explode_agg("id", "c", orig_df, agg_df)
solution_df = pd.DataFrame(orig)

assert_frame_equal(returned_df, solution_df)

def test_index_dtype_with_None(self):
"""Test if dtype of index isn't changed with None values."""
orig = [
{"a": 1, "c": 0},
]
orig = [{"a": 1, "c": 0}]
agg = [{"id": [0, 1], "c": 0}, {"id": [], "c": 1}]
orig_df = pd.DataFrame(orig, columns=["a"])
agg_df = pd.DataFrame(agg)
returned_df = _explode_agg("id", "c", orig_df, agg_df)
solution_df = pd.DataFrame(orig)

assert_frame_equal(returned_df, solution_df)


Expand Down
6 changes: 5 additions & 1 deletion trackintel/preprocessing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def _explode_agg(column, agg, orig_df, agg_df):
temp = agg_df.explode(column)
temp = temp[temp[column].notna()]
temp.index = temp[column]
return orig_df.join(temp[agg], how="left")

return_df = orig_df.join(temp[agg], how="left")
# ensure index dtype the same as input
return_df.index = return_df.index.astype(orig_df.index.dtype)
return return_df


def angle_centroid_multipoints(geometry):
Expand Down