I have merged two dataframes (one between 1998 and 2014 and the other between 2008 and 2016). I want to plot the difference between two time series, one in the first dataframe and the other in the second dataframe. I tried to use this answer to a similar question. There is my code:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
result = pd.merge(data_df, etienne_df, left_index=True, right_index=True, how='outer')
Z = result['1M'] - result['NNGCS01']
mask = ((Z.index.values >= np.datetime64('2008-09-22')) - (Z.index.values <= np.datetime64('2014-02-25'))).any()
Z[mask].plot()
plt.show()
I got the following error:
Traceback (most recent call last):
File "regression.py", line 45, in
Z[mask].plot()
AttributeError: 'numpy.float64' object has no attribute 'plot'
How can I select the time range for my plot?