Open ruanqing976 opened 5 years ago
What is the shape of results.fittedvalues? This works since I tried it on my dataset: plt.plot(df1w['total earnings'], df1w['regular'], '.'). I am guessing plt.plot(df1w['total earnings'], results.fittedvalues, '.') has some issues. You might go check the shape of each series.
Hi I think the error message means that you should have the same dimension for your x and y array. Because python will use your x,y pair to locate a dot to plot.
What is the shape of results.fittedvalues? This works since I tried it on my dataset: plt.plot(df1w['total earnings'], df1w['regular'], '.'). I am guessing plt.plot(df1w['total earnings'], results.fittedvalues, '.') has some issues. You might go check the shape of each series.
Thank you for your help!
Hi I think the error message means that you should have the same dimension for your x and y array. Because python will use your x,y pair to locate a dot to plot.
Thank you for your help!
Hi,
How to solve Matplotlib error ValueError that ask for the same first dimension?
ValueError: x and y must have same first dimension, but have shapes (100,) and (21902,)
Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt
df1w = df1.head(100)
plt.plot(df1w['total earnings'], df1w['regular'], '.') plt.plot(df1w['total earnings'], results.fittedvalues, '.') plt.legend(['actual regular', 'predicted regular'])