这是非常直接的,我试图复制在更快的页面https://github.com/jmcarpenter2/swifter中使用的示例。然而,我一直得到错误AttributeError:'Series‘对象没有属性’更快‘。这是怎么回事?
更新-我试过的例子:
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)发布于 2022-11-09 13:42:23
我也遇到了同样的问题,就这样解决了:
from swifter import swifterhttps://stackoverflow.com/questions/62843445
复制相似问题