Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用groupby时键入错误,Python中的第一个函数,Ipython笔记本,Azure ML_Python_Python 2.7_Group By_Transform_Typeerror - Fatal编程技术网

使用groupby时键入错误,Python中的第一个函数,Ipython笔记本,Azure ML

使用groupby时键入错误,Python中的第一个函数,Ipython笔记本,Azure ML,python,python-2.7,group-by,transform,typeerror,Python,Python 2.7,Group By,Transform,Typeerror,我有一个数据集,我在其中使用特定条件创建一个新列。然后,该列中的值根据列“恒温器”分组 在Jupyter或Azure ML中执行时,我面临以下错误。但在Spyder中成功执行了同样的错误。请告诉我,怎么办 代码: 错误: File ".\Script Bundle\co.py", line 141, in pipeline_1 df['Last_Act_User'] = df.groupby(df['thermostat'].ne(df['thermostat'].shift()).cums

我有一个数据集,我在其中使用特定条件创建一个新列。然后,该列中的值根据列“恒温器”分组

在Jupyter或Azure ML中执行时,我面临以下错误。但在Spyder中成功执行了同样的错误。请告诉我,怎么办

代码:

错误:

  File ".\Script Bundle\co.py", line 141, in pipeline_1
df['Last_Act_User'] = df.groupby(df['thermostat'].ne(df['thermostat'].shift()).cumsum())['Last_Act_User'].transform('first')

  File "C:\pyhome\lib\site-packages\pandas\core\groupby.py", line 2210, in transform
res = wrapper(group)

  File "C:\pyhome\lib\site-packages\pandas\core\groupby.py", line 2203, in <lambda>
wrapper = lambda x: getattr(x, func)(*args, **kwargs)

TypeError: first() takes exactly 2 arguments (1 given)
文件“\Script Bundle\co.py”,第141行,在管道_1中
df['Last_Act_User']=df.groupby(df['automator'].ne(df['automator'].shift()).cumsum())['Last_Act_User'].transform('first'))
文件“C:\pyhome\lib\site packages\pandas\core\groupby.py”,第2210行,在转换中
res=包装器(组)
文件“C:\pyhome\lib\site packages\pandas\core\groupby.py”,第2203行,在
包装器=lambda x:getattr(x,func)(*args,**kwargs)
TypeError:first()正好接受2个参数(给定1个)

在所有环境中运行
pd.\uuuuu version\uuuuuuuuu
,并将结果添加到Spyder中运行Python 2.7.7 | Anaconda 2.0.1(64位)|(默认值,2014年6月11日,10:40:02)[MSC v.1500 64位(AMD64位)]的Azure ML:Microsoft Drawbridge Console主机[版本1.0.2108.0]
  File ".\Script Bundle\co.py", line 141, in pipeline_1
df['Last_Act_User'] = df.groupby(df['thermostat'].ne(df['thermostat'].shift()).cumsum())['Last_Act_User'].transform('first')

  File "C:\pyhome\lib\site-packages\pandas\core\groupby.py", line 2210, in transform
res = wrapper(group)

  File "C:\pyhome\lib\site-packages\pandas\core\groupby.py", line 2203, in <lambda>
wrapper = lambda x: getattr(x, func)(*args, **kwargs)

TypeError: first() takes exactly 2 arguments (1 given)