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

3b6akqbq  于 2023-10-14  发布在  Python
关注(0)|答案(1)|浏览(133)

错误显示“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

qni6mghb

qni6mghb1#

而不是

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)

相关问题