Getting timestamp from the pandas dataframe #676
Replies: 2 comments 5 replies
-
|
I'm really not great at using pandas so I don't know what facilities it provides for plotting. The timestamps are found in the dataframe index. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, So, when converting to dataframe, the timestamps become the index of the Data Frame. you can still use .plot() and specify your y axis with the name of your column. But otherwise, you don't have to convert to csv to plot your signal, convert the MDF to Dataframe, and plot using the signal name. mdf = MDF()
mdf.append(Signal(name="test", samples= np.random.rand(20), timestamps= np.arange(0,10,0.5)))
mdf.append(Signal(name="ECM_test2", samples= np.random.rand(40) + 5, timestamps= np.arange(0,10,0.25)))
mdf_df = mdf.to_dataframe()
mdf_df.plot(y='test')
plt.show()
mdf_df.plot(y='ECM_test2')
plt.show()Perhaps if you would describe what you need to do, we can find a better way to do it. mdf_df.to_csv(f'C:\\test.csv')I get 3 columns as expected: timestamps, test, ECM_test2 [also, converting and saving to csv is highly inefficient in my opinion. you should do it only if you have to or with a very small file] |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I converted the mdf file into csv. Now I want to plot a channel sample versus time using the pandas dataframe.How to do this?
I have plotted the sample vs time using get_can_signal.Now I want to try it with pandas datgaframe.On converting to csv,I didnt,see the timestamp in the dataframe.
I would like to know:
Thank you very much in advance
Beta Was this translation helpful? Give feedback.
All reactions