运行embedded R会得到一个名称

2024-04-24 13:03:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我是一个python新手,正在尝试跟随这个关于寻找季节性客户的伟大博客:

Python Code for Identifying Seasonal Customers

然而,我被困在最后一步。代码如下:

customerTS = stats.ts(dataForOwner.SENDS.astype(int),
        start=base.c(startYear,startMonth),
        end=base.c(endYear, endMonth),
        frequency=12)

我得到这个错误:NameError: name 'dataForOwner' is not defined

编辑我应该补充最后一行也在代码块中,但是我仍然得到错误,没有包括:

customerTS = stats.ts(dataForOwner.SENDS.astype(int),
        start=base.c(startYear,startMonth),
        end=base.c(endYear, endMonth),
        frequency=12)
r.assign('customerTS', customerTS)

我在google上搜索了很多次,但都没有成功。你知道吗


Tags: 代码basestatsstartintendtsastype
1条回答
网友
1楼 · 发布于 2024-04-24 13:03:29
NameError: name 'dataForOwner' is not defined

是由Python自身引发的,表示它无法在当前上下文中找到名为dataForOWner的对象。要亲自体验一下,只需启动一个新的Python终端并键入x(一个不存在的变量名)。你知道吗

问题要么在于你引用的博客(缺少dataForOwner的定义),要么在于试图复制该博客的用户忘记了该定义。你知道吗

相关问题 更多 >