我使用 Dask 读取我的 7GB CSV,但现在出现错误

问题描述 投票:0回答:1

错误显示“NotImplementedError:dd.DataFrame.apply仅支持axis = 1尝试:df.apply(func,axis = 1)”

这是我的代码行:

# Read the CSV file in using dask
import dask.dataframe as dd
df = dd.read_csv('CICIDSs.csv')

features = df.dtypes[df.dtypes !='object'].index
df[features] = df[features].apply(
    lambda x: (x-x.mean())/ (x.std()))
#fill empty values by 0
df_pre = df.fillna(0)
print('===== Data Preprocessing =====')
print(df_pre)

我尝试使用建议的代码,但它输出一个错误,其中显示

func is not defined

python dask
1个回答
0
投票

而不是

df[features] = df[features].apply(
    lambda x: (x-x.mean())/ (x.std()))

你尝试过吗:

df[features] = df[features].apply(
    lambda x: (x-x.mean())/ (x.std()),
    axis=1)
© www.soinside.com 2019 - 2024. All rights reserved.