title: Possible to plot subset of column based on unique value in Pandas?
body: <p>[<em>edited 10/22/19 for clarity</em>]</p>
  
  <p>I'm in the process of learning how to use Pandas.  I have a large data set that I would like to plot (line plot) in various ways.  Here's a mock example, with columns <code>Date</code>, <code>Sample Location</code>, <code>Test1</code>, <code>Test2</code>, <code>Test3</code> (integer): </p>
  
  <pre><code>import itertools
  import pandas as pd
  import numpy as np
  
  # Generate some data; covert dict to dataframe
  MyDates = list(repeat(['1/1/19', '2/1/19', '3/1/19', '4/1/19', '5/1/19'], 5))
  # repeat won't work if run from text editor
  SampleSites = ['Site 1', 'Site 2', 'Site 3', 'Site 4', 'Site 5'] * 5
  Test1 = list(randint(0, 10, 25))
  Test2 = list(randint(0, 10, 25))
  Test3 = list(randint(0, 10, 25))
  MyData = {'Date': MyDates, 'Sample Location': SampleSites, 'Test 1': Test1, 'Test 2': Test2, 'Test 3': Test3}
  DF1 = pd.DataFrame(MyData)
  # Sometimes this doesn't work; not sure why.
  
  </code></pre>
  
  <p>Every thing I've seen in regards to plotting Pandas data frames involves using slicing and methods such as <code>pivot_table</code> and <code>groupby</code> to organize the data in such a way that it can be plotted as desired.  See the following example:</p>
  
  <pre><code># General approach that I have seen others do, I would like a more concise way if possible:
  
  # Plot "Test 1" results for all Sample Locations
  DF2 = DF1.drop(labels = ['Test 2', 'Test 3'], axis = 1)
  DF3 = DF2.pivot_table(index = 'Date', columns = 'Sample Location')
  DF3.plot()
  
  # Plot columns Test 1, Test 2, and Test 3 for Sample Location 'Site 1'
  # Select subset of data from DF1 to plot
  FilterSamples = ['Site 1']
  # Slice data frame down to desired type
  DF2 = DF1[DF1['Sample Location'].isin(FilterSamples)]
  DF3 = DF2.reset_index(drop = True)
  DF3.plot(x = 'Date', y = ['Test 1', 'Test 2', 'Test 3'])
  
  </code></pre>
  
  <p>This approach seems cumbersome as it seems to require several objects to be passed to get to where the data needs to be for plotting.</p>
  
  <p>It would be great if I could have a concise way to plot from a large data frame, where x and y values can be filtered per adjacent values in the row.  For example, instead of filtering the data frame to only include Sample Location 'Site 1', it would be great if I could write something like the following:</p>
  
  <pre><code># pseudo-code example of what I would like to do:
  # Only plots x values (date) of rows with Site 1 value in Sample Location column
  # Only plots corresponding y values for column Test 1
  DF1.plot (x = DF1.Date[DF1.Sample Location['Site 1']], y = DF1.Test1)
  
  # Is something like this possible?
  
  </code></pre>
  
  <p>Hopefully the the question is more clear now.  Any suggestions/criticisms regarding the primary question or any aspect of my code will be appreciated!</p>