From df21b025a02a674728c10898d6fb15f2e857f0b0 Mon Sep 17 00:00:00 2001 From: "Kniffin, Charles" Date: Mon, 9 Dec 2024 15:07:29 -0800 Subject: [PATCH 1/3] fix: handle duplicated channels in tdms * updated tdms channel handling to deal with the same channel names accross different groups * changed merge suffixes to prevent confusion with coordinate systems --- nominal/_tdms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nominal/_tdms.py b/nominal/_tdms.py index f2b62a0..f17864c 100644 --- a/nominal/_tdms.py +++ b/nominal/_tdms.py @@ -14,10 +14,10 @@ def tdms_with_time_column_to_pandas(path: Path, timestamp_column: str) -> pd.DataFrame: group_dfs: list[pd.DataFrame] = [] - channels_to_export: dict[str, pd.Series[Any]] = {} with TdmsFile.open(path) as tdms_file: for group, time_channel in _get_groups_with_time_channel(tdms_file.groups(), timestamp_column): + channels_to_export: dict[str, pd.Series[Any]] = {} for channel in _get_export_channels(group.channels(), time_channel, timestamp_column): channel_name = _create_channel_name(group, channel) channels_to_export[channel_name] = pd.Series(data=channel.read_data(), index=time_channel.read_data()) @@ -27,7 +27,7 @@ def tdms_with_time_column_to_pandas(path: Path, timestamp_column: str) -> pd.Dat # format for nominal upload df = functools.reduce( - lambda left, right: pd.merge(left, right, left_index=True, right_index=True, how="outer"), group_dfs + lambda left, right: pd.merge(left, right, left_index=True, right_index=True, how="outer", suffixes=['_repeated_1, _repeated_2']), group_dfs ) df.index = df.index.set_names(timestamp_column, level=None) df = df.reset_index() From 0958e57c4fdb97d34b75ee585ff93d7cb09581b7 Mon Sep 17 00:00:00 2001 From: "Kniffin, Charles" Date: Tue, 10 Dec 2024 10:36:13 -0800 Subject: [PATCH 2/3] fix: formatting fixes --- nominal/_tdms.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nominal/_tdms.py b/nominal/_tdms.py index f17864c..7e65e1b 100644 --- a/nominal/_tdms.py +++ b/nominal/_tdms.py @@ -27,7 +27,10 @@ def tdms_with_time_column_to_pandas(path: Path, timestamp_column: str) -> pd.Dat # format for nominal upload df = functools.reduce( - lambda left, right: pd.merge(left, right, left_index=True, right_index=True, how="outer", suffixes=['_repeated_1, _repeated_2']), group_dfs + lambda left, right: pd.merge( + left, right, left_index=True, right_index=True, how="outer", suffixes=["_repeated_1, _repeated_2"] + ), + group_dfs, ) df.index = df.index.set_names(timestamp_column, level=None) df = df.reset_index() From 241e47aaa53ec1f8cace253300a31875fe059804 Mon Sep 17 00:00:00 2001 From: "Kniffin, Charles" Date: Wed, 11 Dec 2024 08:22:19 -0800 Subject: [PATCH 3/3] fix: corrected typo in suffixes --- nominal/_tdms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nominal/_tdms.py b/nominal/_tdms.py index 7e65e1b..d3c3cdb 100644 --- a/nominal/_tdms.py +++ b/nominal/_tdms.py @@ -28,7 +28,7 @@ def tdms_with_time_column_to_pandas(path: Path, timestamp_column: str) -> pd.Dat # format for nominal upload df = functools.reduce( lambda left, right: pd.merge( - left, right, left_index=True, right_index=True, how="outer", suffixes=["_repeated_1, _repeated_2"] + left, right, left_index=True, right_index=True, how="outer", suffixes=["_repeated_1", "_repeated_2"] ), group_dfs, )