I am trying to create a pandas dataframe that looks like this:
-5 0 5 index -5 NaN slope slope 0 slope NaN slope 5 slope slope NaN but the closest I can get is the code below which returns a dataframe with only one column (which is the list from the last iteration through the ctr1 loop)
weather = np.linspace(-5, 5, 3) for ctr1 in weather: slope_list = [] X1 = round(ctr1,1) for ctr2 in weather: X2 = round(ctr2,1) Y1 = regressor[0] * X1**3 + \ regressor[1] * X1**2 + \ regressor[2] * X1 + \ regressor[3] Y2 = regressor[0] * X2**3 + \ regressor[1] * X2**2 + \ regressor[2] * X2 + \ regressor[3] slope = (Y2-Y1)/(X2-X1) slope_list.append(slope) df_final = pd.DataFrame({X1:slope_list}) Can anyone help?