Plot each unique element of a column in a dataframe with partially overlapping y-Values
<p>I hope I can explain this properly as I am new to pandas. I have the following dataframe in pandas.</p>

<pre><code>import numpy as np
plant1 = {'Date' : pd.date_range('1/1/2011', periods=10, freq='D'),
     'Plant' : pd.Series(["Plant1"]*10),
     'Output' : pd.Series(abs(np.random.randn(10)))}

plant2 = {'Date' : pd.date_range('1/3/2011', periods=10, freq='D'),
     'Plant' : pd.Series(["Plant2"]*10),
     'Output' : pd.Series(abs(np.random.randn(10)))}

plant3 = {'Date' : pd.date_range('1/5/2011', periods=10, freq='D'),
     'Plant' : pd.Series(["Plant3"]*10),
     'Output' : pd.Series(abs(np.random.randn(10)))}     



df_plant_1 = pd.DataFrame(plant1)
df_plant_2 = pd.DataFrame(plant2)
df_plant_3 = pd.DataFrame(plant3)

sample = pd.concat([df_plant_1,df_plant_2,df_plant_3])
</code></pre>

<p>My output is meant to be an area plot with each individual plant and the respective y-Value (Output) and x-value (Date). Notice that "Dates" are only partially overlapping.</p>

<p>I am stuck at finding a way to meaningful organize my data. The first challenge is to merge the data for duplicate "Date"-Values. The next step would be to fill the resulting holes in the series with .fillna(). The final step would be to plot for each unique "Plant"-value.</p>

<p>However, I am already stuck at the first step. I am aware of the .merge function, but don't know how to apply it to this case.</p>

<p>Thank you for your time and consideration.</p>

<p>A user in the chat made me aware of the pivot-function.</p>

<pre><code>test = pd.pivot_table(sample, index='Date', columns='Plant', values='Output')
test = test.fillna(method='pad')                            
test = test.fillna(method='bfill')        

plt.figure(); test.plot(kind='area')
</code></pre>

<p><a href="https://i.stack.imgur.com/QmtA4.png" rel="nofollow"><img src="https://i.stack.imgur.com/QmtA4.png" alt="enter image description here"></a></p>

python pandas