Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.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
Python 如何修复错误AttributeError:';系列';对象没有属性';更快';?_Python_Pandas_Swifter - Fatal编程技术网

Python 如何修复错误AttributeError:';系列';对象没有属性';更快';?

Python 如何修复错误AttributeError:';系列';对象没有属性';更快';?,python,pandas,swifter,Python,Pandas,Swifter,这非常直接,我试图复制Swifter page中使用的示例。但是,我不断得到错误AttributeError:“Series”对象没有属性“swifter”。怎么回事 更新-我尝试的示例: import pandas as pd import swifter df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [5, 6, 7, 8]}) # runs on single core df['x2'] = df['x'].apply(lambda x: x*

这非常直接,我试图复制Swifter page中使用的示例。但是,我不断得到错误AttributeError:“Series”对象没有属性“swifter”。怎么回事

更新-我尝试的示例:

import pandas as pd
import swifter 

df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [5, 6, 7, 8]})

# runs on single core
df['x2'] = df['x'].apply(lambda x: x**2)
# runs on multiple cores
df['x2'] = df['x'].swifter.apply(lambda x: x**2)

# use swifter apply on whole dataframe
df['agg'] = df.swifter.apply(lambda x: x.sum() - x.min())

# use swifter apply on specific columns
df['outCol'] = df[['inCol1', 'inCol2']].swifter.apply(my_func)
df['outCol'] = df[['inCol1', 'inCol2', 'inCol3']].swifter.apply(my_func,
         positional_arg, keyword_arg=keyword_argval)

请提供完整的错误输出,以及一个简单的示例。您有什么版本?尝试更新到最新的verison。@amc该示例正是您在我发布的链接中看到的。同样,这里只有一个带有df.swifter.apply()的小脚本,它就是我used@DavidErickson我以为我有上一个版本,因为我刚刚安装了你可以下载'status.csv'和'trip.csv'。这些文件在您当前的目录中吗?请提供完整的错误输出,以及一个文件。您有什么版本?尝试更新到最新的verison。@amc该示例正是您在我发布的链接中看到的。同样,这里只有一个带有df.swifter.apply()的小脚本,它就是我used@DavidErickson我以为我有上一个版本,因为我刚刚安装了你可以下载'status.csv'和'trip.csv'。这些文件在您当前的目录中吗?