python - Pandas 重新采样错误:resample() 得到了一个意外的关键字参数“偏移量”
问题描述
我正在尝试重新采样数据框,并且我想抵消数据。我收到错误:
resample() got an unexpected keyword argument 'offset'
我尝试运行 pandas文档中的示例代码。
start, end = '2000-10-01 23:30:00', '2000-10-02 00:30:00'
rng = pd.date_range(start, end, freq='7min')
ts = pd.Series(np.arange(len(rng)) * 3, index=rng)
ts.resample('17min', offset='23h30min').sum()
这会导致相同的错误。我已将 pandas 升级到当前的最新版本('1.0.3')。
更新:
在文档中,在偏移下它声明“1.1.0 版中的新功能”。
解决方案
解决方案是安装pandas 1.1.0。可以通过从源代码构建熊猫来完成。
从 github 克隆开发版的 pandas:
git clone https://github.com/pandas-dev/pandas/releases
安装cython:
pip install cython
cd pandas,然后:
python -m pip install -e . --no-build-isolation --no-use-pep517
推荐阅读
- python - 在 4 个 CPU 上执行 CPU 密集型任务时,20 个进程中的 400 个线程优于 4 个进程中的 400 个线程
- powershell - 在当前 Powershell 会话中启动后台进程
- javascript - 如何使用 Selenium 从亚马逊上的自动建议中“点击”某些建议?
- excel - 如何根据包含昼夜温度数据的表获取日期时间值的温度
- python - 将文件中的单行读取为 numpy.array 的单行脚本
- android - 如何使用ffmpeg并排创建两个带有填充和图像背景的视频?
- python - Lark 解析器语法适用于 Earley,但不适用于 LALR
- java - 错误:(107、9)java:找不到符号符号:方法loadConfiguration()?
- regex - 将电子邮件地址插入 sender_access_regexp 的脚本(并添加正则表达式)
- arcgis-js-api - 将 JavaScript API 3.10 与 ArcGIS Server 10.6 结合使用