title: Why do I have different array dimensions only when not using todays date?
body: <p>I am trying to get stock data for a company and predict stock prices in the future. I know this isn't accurate, but I am using it as a learning tool. When using today's date as the end date and the predicted date as a date in the future my code appears to work. However, when using a past date and predicting the future this produces an error:</p>
  
  <p>"ValueError: x and y must have same first dimension, but have shapes (220,) and (221,)"</p>
  
  <p>I want to do this as then I would be able to compare predictions to actual prices.</p>
  
  <pre><code>import numpy as np
  import datetime
  import pandas_datareader as web
  import statistics
  import matplotlib.pyplot as plt
  import pandas as pd
  from matplotlib import style
  from sklearn.linear_model import LinearRegression
  from sklearn.model_selection import train_test_split
  from pandas.plotting import register_matplotlib_converters
  register_matplotlib_converters()
  
  stock_name = 'BP.L'
  
  prices = web.DataReader(stock_name, 'yahoo', start = '2019-01-01', end = '2019-11-05').reset_index(drop = False)[['Date', 'Adj Close']]
  
  
  #plt.plot(prices['Date'], prices['Adj Close'])
  #plt.xlabel('Days')
  #plt.ylabel('Stock Prices')
  #plt.show()
  
  
  # Parameter Definitions
  
  # So    :   initial stock price
  # dt    :   time increment -&gt; a day in our case
  # T     :   length of the prediction time horizon(how many time points to predict, same unit with dt(days))
  # N     :   number of time points in the prediction time horizon -&gt; T/dt
  # t     :   array for time points in the prediction time horizon [1, 2, 3, .. , N]
  # mu    :   mean of historical daily returns
  # sigma :   standard deviation of historical daily returns
  # b     :   array for brownian increments
  # W     :   array for brownian path
  
  start_date = '2018-01-01'
  end_date = '2019-01-01'
  pred_end_date = '2019-11-05'
  
  # We get daily closing stock prices
  S_eon = web.DataReader(stock_name, 'yahoo', start_date, end_date).reset_index(drop = False)[['Date', 'Adj Close']]
  
  So = S_eon.loc[S_eon.shape[0] -1, "Adj Close"]
  
  dt = 1
  
  n_of_wkdays = pd.date_range(start = pd.to_datetime(end_date, 
                format = "%Y-%m-%d") + pd.Timedelta('1 days'), 
                end = pd.to_datetime(pred_end_date, 
                format = "%Y-%m-%d")).to_series(
                ).map(lambda x: 
                1 if x.isoweekday() in range(1,6) else 0).sum()
  T = n_of_wkdays
  
  N = T / dt
  
  t = np.arange(1, int(N) + 1)
  
  returns = (S_eon.loc[1:, 'Adj Close'] - \
            S_eon.shift(1).loc[1:, 'Adj Close']) / \
            S_eon.shift(1).loc[1:, 'Adj Close']
  
  mu = np.mean(returns)
  
  sigma = np.std(returns)
  
  
  scen_size = 10000
  b = {str(scen): np.random.normal(0, 1, int(N)) for scen in range(1, scen_size + 1)}
  
  W = {str(scen): b[str(scen)].cumsum() for scen in range(1, scen_size + 1)}
  
  drift = (mu - 0.5 * sigma**2) * t
  diffusion = {str(scen): sigma * W[str(scen)] for scen in range(1, scen_size + 1)}
  
  S = np.array([So * np.exp(drift + diffusion[str(scen)]) for scen in range(1, scen_size + 1)]) 
  S = np.hstack((np.array([[So] for scen in range(scen_size)]), S))
  S_avg = np.mean(S)
  print(S_avg)
  
  #Plotting 
  plt.figure(figsize = (20,10))
  for i in range(scen_size):
      plt.title("Daily Volatility: " + str(sigma))
      plt.plot(pd.date_range(start = S_eon["Date"].max(), 
                  end = pred_end_date, freq = 'D').map(lambda x:
                  x if x.isoweekday() in range(1, 6) else np.nan).dropna(), S[i, :])
      plt.ylabel('Stock Prices, €')
      plt.xlabel('Prediction Days')
  plt.show()
  </code></pre>
  
  <p>The error shows: </p>
  
  <p>"File "C:\Users\User\Anaconda3\lib\site-packages\matplotlib\axes_base.py", line 270, in _xy_from_xy
      "have shapes {} and {}".format(x.shape, y.shape))"</p>