Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
476 views
Kernel: Anaconda (Python 3)
%matplotlib notebook # plt is the library with all the plotting import matplotlib.pyplot as plt # pd is the library with the spreadsheet functions import pandas as pd # Also, be sure the kernel is set to ENSP-437 in the Kernel/Change Kernel menu.

Reading data

We are going to use code to read in data from our box experiments and plot it.

Read the lesson in the computing-tutorial on CSV files.

You have access to two files

  • 2016-02-16-combined.csv

  • 2016-02-26-combined.csv

Go to the file browser and click on the file. You can see what it looks like inside.

Loading data

We are going to do the following.

  • Load in a data file using the pd.read_csv(filename) command. Note that you have to put the filename between quotes for the computer.

  • Place this in a variable named data.

  • Understand what the columns of data are.

  • Plot the data.

  • Calculate some statistics about the data.

  • Calculate a difference in temperature from the data.

Conceptual questions

  • What does it mean to load a data file?

  • What does the computer do when it plots your data?

  • How does the computer calculate statistics?

data1 = pd.read_csv('2016-02-16-combined.csv') data2 = pd.read_csv('2016-02-26-combined.csv') plt.plot(data1['time'], data1['t_in']-data1['t_out'], label='16th') plt.plot(data2['time'], data2['t_in']-data2['t_out'], label='26th') plt.legend() plt.grid() plt.xlabel('time (sec)') plt.ylabel('Temp Difference (C)')
<IPython.core.display.Javascript object>
<matplotlib.text.Text at 0x7fe2545e05f8>