- Read in the sensors dataset and identify the variables:
>>> sensors = pd.read_csv('data/sensors.csv')>>> sensors
- The only variable placed correctly in a vertical column is Group. The Property column appears to have three unique variables, Pressure, Temperature, and Flow. The rest of the columns 2012 to 2016 are themselves a single variable, which we can sensibly name Year. It isn't possible to restructure this kind of messy data with a single DataFrame method. Let's begin with the melt method to pivot the years into their own column:
>>> sensors.melt(id_vars=['Group', 'Property'], var_name='Year') \ .head(6)
- This takes ...