I'm using a NI DAQ to make continuous temperature measurements. I have a real-time plot of the two thermocouples working, but I can't get the two columns (Freezer Temperature and Right Side) to be in a continuously built dataframe. When I run this I get "Can only append a Series if ignore_index=True or if the Series has a name". But when I then add ignore_index=True to df.append(Col) it says "append() takes no keyword arguments".
I eventually want to put this dataframe into a CSV file.
I'm hoping that someone here can help me. I figure it might be awkward to troubleshoot if you don't have a DAQ by you to try, but it's worth a shot.
Thanks!
import nidaqmx
import matplotlib.pyplot as plt
import pandas as pd
plt.ion()
i = 0
df = []
while i >= 0:
with nidaqmx.Task() as task:
FreezerT = task.ai_channels.add_ai_thrmcpl_chan("cDAQ1Mod1/ai0")
RightSideT = task.ai_channels.add_ai_thrmcpl_chan("cDAQ1Mod1/ai3")
task.timing.samp_clk_rate = 1
data = task.read()
plt.scatter(i,data[0],c='r')
plt.scatter(i,data[1],c='b')
plt.xlabel('Time (s)')
plt.ylabel('Temperature (C)')
plt.pause(0.05)
i = i + 1
Col = {'Time (s)': i,
'Freezer Temperature': data[0],
'Right Side': data[1]}
df.append(Col)
df = pd.DataFrame(df, columns = ['Time (s)','Freezer Temperature', 'Right Side'])
print(df)