Python3报错:FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.

本文解决了一个Python3中常见的警告信息:FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead. 通过将as_matrix()替换为values,可以避免此警告并保持代码的向前兼容性。

Python3报错:FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.

orig_data = pdData.as_matrix()

解决办法根据报错提示将as_matrix()改为values

orig_data = pdData.values

 

C:\Users\1\PycharmProjects\pythonProject1\.venv\Scripts\python.exe C:\Users\1\PycharmProjects\pythonProject1\python2.py 开始加载数据... price数据集: 7393条记录, 时间范围: 2025-01-27 00:00:00 至 2025-04-14 00:00:00 wind数据集: 2256条记录, 时间范围: 2025-01-27 00:00:00 至 2025-04-30 23:00:00 pv数据集: 2254条记录, 时间范围: 2025-01-27 00:00:00 至 2025-04-30 23:00:00 load数据集: 35712条记录, 时间范围: 2025-01-27 00:00:00 至 2025-05-30 23:55:00 weather数据集: 2587条记录, 时间范围: 2025-01-27 00:00:00 至 2025-05-14 18:00:00 统一时间频率... === 数据重采样到小时频率 === price: 原始点 7393 → 对齐后 2977 wind: 原始点 2256 → 对齐后 2977 pv: 原始点 2254 → 对齐后 2977 load: 原始点 35712 → 对齐后 2977 weather: 原始点 2587 → 对齐后 2977 处理缺失值... === 缺失值处理 === price缺失值: 1128/2977 (37.9%) 处理后缺失值: 0/2977 (0.0%) wind缺失值: 721/2977 (24.2%) 处理后缺失值: 0/2977 (0.0%) pv缺失值: 723/2977 (24.3%) 处理后缺失值: 0/2977 (0.0%) load缺失值: 1/2977 (0.0%) 处理后缺失值: 0/2977 (0.0%) weather缺失值: 2730/20839 (13.1%) C:\Users\1\PycharmProjects\pythonProject1\python2.py:104: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. start=all_indices.min().floor('H'), C:\Users\1\PycharmProjects\pythonProject1\python2.py:105: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. end=all_indices.max().ceil('H'), C:\Users\1\PycharmProjects\pythonProject1\python2.py:103: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. full_range = pd.date_range( C:\Users\1\PycharmProjects\pythonProject1\python2.py:115: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. resampled = df[[value_col]].resample('H').mean() C:\Users\1\PycharmProjects\pythonProject1\python2.py:115: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. resampled = df[[value_col]].resample('H').mean() C:\Users\1\PycharmProjects\pythonProject1\python2.py:115: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. resampled = df[[value_col]].resample('H').mean() C:\Users\1\PycharmProjects\pythonProject1\python2.py:115: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. resampled = df[[value_col]].resample('H').mean() C:\Users\1\PycharmProjects\pythonProject1\python2.py:122: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. avg_df = df[num_cols].resample('H').mean() if num_cols else pd.DataFrame() 处理后缺失值: 0/20839 (0.0%) 合并数据并创建特征... === 数据合并与特征工程 === 合并后数据集形状: (2977, 19) 时间范围: 2025-01-27 00:00:00 至 2025-05-31 00:00:00 分析数据并生成可视化... === 数据分析与可视化 === 数据集统计信息: C:\Users\1\PycharmProjects\pythonProject1\python2.py:186: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. full_index = pd.date_range(start=start_time, end=end_time, freq='H') C:\Users\1\PycharmProjects\pythonProject1\.venv\Lib\site-packages\pandas\core\nanops.py:1016: RuntimeWarning: invalid value encountered in subtract sqr = _ensure_numeric((avg - values) ** 2) price wind_power ... price_lag_24 renewable_ratio count 2977.000000 2977.000000 ... 2977.000000 2977.000000 mean 150.692672 224.970671 ... 153.171678 inf std 172.261384 179.781908 ... 172.862336 NaN min 40.000000 0.000000 ... 40.000000 -353.491724 25% 40.000000 109.939700 ... 40.000000 -1.699921 50% 40.000000 145.094600 ... 40.000000 -0.649429 75% 260.250000 342.681600 ... 266.600000 0.424216 max 1000.000000 733.462100 ... 1000.000000 inf [8 rows x 19 columns] 与电价相关性最高的因素: price 1.000000 price_lag_1 0.867507 price_lag_2 0.707098 price_lag_24 0.671070 price_lag_3 0.581216 load 0.471979 weather_6 0.250627 weather_3 0.228792 weather_2 0.100665 hour 0.081669 Name: price, dtype: float64 程序执行出错: When stacked is True, each column must be either all positive or all negative. Column 'pv_power' contains both positive and negative values 建议检查: 1. 文件路径是否正确 2. Excel文件中的实际列名 3. 数据文件是否被其他程序占用 4. 日期格式是否正确 进程已结束,退出代码为 0
最新发布
12-06
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangvalue

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值