已有183人关注
第二章的源码下载后运行不了
发表在Python图书答疑 2022-02-04 《Python项目开发实战入门》第2章 销售收入分析与预测
是否精华
版块置顶:
也按书里下载了第三方模块运行后就一大堆红的 帮我看看、
D:\新建文件夹\02\JDData_month.py:27: FutureWarning: As the xlwt package is no longer maintained, the xlwt engine will be removed in a future version of pandas. This is the only engine in pandas that supports writing in the xls format. Install openpyxl and write to an xlsx file instead. You can set the option io.excel.xls.writer to 'xlwt' to silence this warning. While this option is deprecated and will also raise a warning, it can be globally set and the warning suppressed.
  dfData_month.to_excel(resultfile1) #导出结果
D:\新建文件夹\02\JDData_month.py:28: FutureWarning: As the xlwt package is no longer maintained, the xlwt engine will be removed in a future version of pandas. This is the only engine in pandas that supports writing in the xls format. Install openpyxl and write to an xlsx file instead. You can set the option io.excel.xls.writer to 'xlwt' to silence this warning. While this option is deprecated and will also raise a warning, it can be globally set and the warning suppressed.
  dfCar_month.to_excel(resultfile2) #导出结果
F:\新建文件夹 (6)\lib\site-packages\sklearn\linear_model\_base.py:148: FutureWarning: 'normalize' was deprecated in version 1.0 and will be removed in 1.2. Please leave the normalize parameter to its default value to silence this warning. The default behavior of this estimator is to not do any normalization. If normalization is needed please use sklearn.preprocessing.StandardScaler instead.
               支出
投放日期             
2018-01  13985.51
2018-02   6265.78
2018-03  12116.45
2018-04  15832.77
2018-05  18064.53
2018-06  57013.59
  warnings.warn(
7月投放60000元广告费,预计销售收入 373828.90186837834 元
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexes\base.py", line 3621, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas\_libs\index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 142, in pandas._libs.index.IndexEngine.get_loc
TypeError: '(slice(None, None, None), None)' is an invalid key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\新建文件夹\02\JDData_month.py", line 51, in <module>
    plt.plot(x,y_pred, color='blue', linewidth=1.5) #预测回归线
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\matplotlib\pyplot.py", line 2757, in plot
    return gca().plot(
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_axes.py", line 1632, in plot
    lines = [*self._get_lines(*args, data=data, **kwargs)]
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 312, in __call__
    yield from self._plot_args(this, kwargs)
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 487, in _plot_args
    x = _check_1d(xy[0])
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\matplotlib\cbook\__init__.py", line 1327, in _check_1d
    ndim = x[:, None].ndim
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\pandas\core\frame.py", line 3506, in __getitem__
    indexer = self.columns.get_loc(key)
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexes\base.py", line 3628, in get_loc
    self._check_indexing_error(key)
  File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexes\base.py", line 5637, in _check_indexing_error
    raise InvalidIndexError(key)
pandas.errors.InvalidIndexError: (slice(None, None, None), None)

进程已结束,退出代码为 1


分享到:
精彩评论 2
淡.印象
学分:323 LV5
TA的每日心情
学习Python
2020-11-23 22:17:24
2022-02-09
沙发

读者您好:

由于模块版本问题,出现了两个警告,具体解决方法如下:

第1个警告,修改如下代码

resultfile1=r'result1.xls'

resultfile2=r'result2.xls'

修改为:

resultfile1=r'result1.xlsx'

resultfile2=r'result2.xlsx'


第2个警告,修改如下代码

clf=linear_model.LinearRegression(fit_intercept=True,normalize=False)

修改为

clf=linear_model.LinearRegression(fit_intercept=True)


game99258
学分:2266 LV10
2022-07-25
板凳

路径不对吧

首页上一页 1 下一页尾页 2 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照