Jer*_*att 2 python warnings date-range pandas
编辑 6/20/18:
正如@aydow 所指出的,这类似于: 如何抑制熊猫未来警告?
该页面的解决方案确实消除了我的警告:
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
Run Code Online (Sandbox Code Playgroud)
但是,没有讨论为什么(一旦我运行 pd.date_range)我在控制台中输入的每个命令都会收到警告。
/结束编辑 6/20/18
第一次发帖,所以如果我搞砸了任何事情或遗漏了任何重要信息,我深表歉意。我对 python 也很陌生,所以我很可能在某个地方犯了一个愚蠢的错误。但是,我找不到有关此问题的任何信息。
由于我缺乏更好的词汇,我将警告称为“粘性” - 一旦我收到一次警告(它在运行 pandas.date_range 后出现),无论我在 python 中输入什么,我都会收到几乎相同的警告安慰。我正在尝试做的事情和结果的详细信息如下。
预先感谢您的任何帮助,
-杰里米
任务:
给定起始年份、多个 bin 和一个时间步长,我尝试使用 pandas date_range 函数创建一系列时间戳。示例代码:
import pandas as pd
NumBins = 10
timestep=3
startYr = 2018
BinList =
pd.date_range(start='1/1/'+str(startYr),periods=NumBins,freq=str(timestep)+'min')
Run Code Online (Sandbox Code Playgroud)
虽然这确实导致了预期的输出(从 2018 年 1 月 1 日午夜开始,每 3 分钟有 10 个时间戳),但我收到以下警告消息:
C:\Users\mattje\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\widgets\variableexplorer\utils.py:414: FutureWarning: 'summary' is deprecated and will be removed in a future version.
display = value.summary()
Run Code Online (Sandbox Code Playgroud)
题:
为什么无论我尝试检查什么变量,在我运行 date_range 函数后都会开始显示此警告消息?
例如,如果我运行前 4 行代码,然后在控制台中输入 'timestep' 我得到以下信息,我得到以下信息(注意输出后没有警告):
import pandas as pd
NumBins = 10
timestep=3
startYr = 2018
timestep
Out[2]: 3
Run Code Online (Sandbox Code Playgroud)
在我运行之后
pd.date_range(start='1/1/'+str(startYr),periods=NumBins,freq=str(timestep)+'min')
Run Code Online (Sandbox Code Playgroud)
行,当我在控制台中输入“timestep”时,我得到以下信息:
timestep
Out[4]: 3C:\Users\mattje\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\widgets\variableexplorer\utils.py:414: FutureWarning: 'summary' is deprecated and will be removed in a future version.
display = value.summary()
Run Code Online (Sandbox Code Playgroud)
如果我创建一个新变量,我会得到:
test = 5
C:\Users\mattje\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\widgets\variableexplorer\utils.py:414: FutureWarning: 'summary' is deprecated and will be removed in a future version.
display = value.summary()
Run Code Online (Sandbox Code Playgroud)
如果我导入 numpy 我得到:
import numpy as np
C:\Users\mattje\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\widgets\variableexplorer\utils.py:414: FutureWarning: 'summary' is deprecated and will be removed in a future version.
display = value.summary()
Run Code Online (Sandbox Code Playgroud)
其他信息
小智 5
请尝试以下操作:
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
Run Code Online (Sandbox Code Playgroud)