When instanciating CausalImpact with date ranges for pre/post periods, the method plot causes matplotlib to fail: "ConversionError: Failed to convert value(s) to axis units".
This is because of matplotlib expects Timestamps on the horizontal axis of the plot created using a DatetimeIndex (self.data.index) and fails to convert the provided String argument (data_inter).
Here's a minimal code to reproduce this:
import numpy as np
import pandas as pd
self_data_index = pd.date_range('2021-01-01', '2021-01-31')
data_inter = '2021-01-15'
plt.plot(self_data_index, np.zeros(self_data_index.shape[0]))
plt.axvline(data_inter) # Fails
>>> ConversionError: Failed to convert value(s) to axis units: '2021-01-15'
plt.axvline(pd.Timestamp(data_inter)) # Works
>>> Works.
When instanciating
CausalImpact
with date ranges for pre/post periods, the methodplot
causes matplotlib to fail: "ConversionError: Failed to convert value(s) to axis units".This is because of matplotlib expects Timestamps on the horizontal axis of the plot created using a DatetimeIndex (self.data.index) and fails to convert the provided String argument (data_inter).
Here's a minimal code to reproduce this: