Hi everyone,
I’m working with MF4 recording files in Alteryx and I want to plot a specific signal (e.g., Torque) correctly.
Problem:
When I use mdf.to_dataframe([signal]) and save it to CSV, the values don’t match the plots I get in n8n.
Reason: to_dataframe([signal]) creates a common time axis for multiple signals, which causes the values to be interpolated.
Goal:
Plot the signal directly in the Alteryx Python Tool.
Use the exact original timestamps and signal values from the MF4 file without any interpolation.
Questions:
How can I load the MF4 file directly in the Alteryx Python Tool and plot the signal correctly?
Are there any best practices to keep the original time axis and signal values from the MF4 file?
Thanks for any help!
Could you try to put your code in Python instead of the Python tool in Alteryx and see if it still plots incorrectly? If so, the reason may come from your Python code rather than the tool
This be what chatgpt says --->
import pandas as pd
from asammdf import MDF
# Load your MDF file
mdf_file = MDF('your_file.mf4')
# Create a dictionary to store each signal as a separate DataFrame
signal_dataframes = {}
# Iterate over all signals in the MDF file
for signal in mdf_file.iter_signals():
# Create a DataFrame for each signal with its native timestamps
signal_df = pd.DataFrame(
{signal.name: signal.samples},
index=signal.timestamps
)
# Store the DataFrame in the dictionary
signal_dataframes[signal.name] = signal_df
# You can access each signal with its original timestamps
# For example, to view the "Signal_A" data:
# print(signal_dataframes['Signal_A'])
# You can also merge them, but the index will be a combination of all timestamps.
# The `use_interpolation=False` parameter in to_dataframe is similar to this,
# but can be slower and still results in a common index with NaNs.
# A simple merge will also result in a common index with NaNs.
# full_df = pd.concat(signal_dataframes.values(), axis=1, join='outer')
having said that --- ummm. you're using an N8N node you didn't create yourself in a corporate environment? Maybe look at what N8N is doing and replicate it?