


This creates a variable representing the plot that you can then edit as desired to make the image you want. The first step in plotting with subplots is creating the subplot object. Get More With Grant Model Validation and Testing: A Step-by-Step Guide Once you’re satisfied that you understand what’s in the DataFrame, we’re ready to start plotting! # Viewing the dataframe using IPython.display Those options are as follows: # Viewing the dataframe by printing Within Python, you can either print the DataFrame or use IPython’s display function for a more user-friendly view. You can do this outside of Python by opening the. Oh, one more thing: If you aren’t familiar with the data set you might want to see what’s in it before continuing. You can do this with the pandas.to_datetime() function: data.index = pd.to_datetime(data.index)Īnd we’re all done! The DataFrame is now ready for plotting. To avoid a headache later, you’ll want to convert the index to a date/time index. For many purposes this doesn’t matter, but Matplotlib makes axis formatting choices differently if you’re working with a string versus a date/time object. One thing that’s important to know is the date/time data used as the index is currently read as a string, not as a date/time object. The data set is now saved in the variable data and the index of the DataFrame is set to the first column, which stores the date and time of each measurement. Your code should appear as follows: import pandas as pdĭata = pd.read_csv('COP_HPWH_f_Tamb&Tavg.csv', index_col = 0)Īnd that’s it.

If you’ve downloaded the data set and stored it in the same working directory as your script you can import it using the pandas.read_csv() function by solely calling the file name. I previously introduced the concepts in the introduction to a detailed data analysis tutorial, and have made the data set available online for those who wish to follow along. Scientists perform experiments on these products on a regular basis, and the data set replicates tests I’ve personally performed. In this tutorial we’ll create plots representing laboratory data collected during experiments studying the performance of residential heat pump water heaters. Before we can start plotting, we need a data set.
