我正在使用Python,在使用以下代码时
df['timestamp'] = df.groupby(["id"]).timestamp.transform(np.ptp)我收到警告FutureWarning: Method .ptp is deprecated and will be removed in a future version. Use numpy.ptp instead.了。df是熊猫DataFrame,timestamp和id是columns。我认为np.ptp引起了这一警告。
我要换什么?
发布于 2019-08-26 18:50:04
这意味着方法.ptp被否决,以支持(从我所读到的)函数np.ptp(),因此您可以设置警告为false,以避免读取它,或者将该方法替换为numpy似乎建议的函数。
如果您希望抑制警告,可以尝试使用:warnings.filterwarnings(“忽略”)或warnings.simplefilter(“忽略”,FutureWarning),如果您忽略的只是FutureWarning。
https://stackoverflow.com/questions/57662975
复制相似问题