问题描述
data.dtypes()
id object
comment_text object
toxic int64
severe_toxic int64
obscene int64
threat int64
insult int64
identity_hate int64
dtype: object
由于int64
占用了更多空间,因此我试图将数字列转换为uint8.
,这是我的代码;
data[["toxic","severe_toxic","obscene","threat","insult","identity_hate"]] = data[
["toxic","identity_hate"]
].swifter.apply(np.uint8,axis=0)
由于我要将函数应用于每一列,因此我使用了axis=0
,这也是默认设置。但是即使在运行此代码之后,这还是新的输出;
data.dtypes
id object
comment_text object
toxic int64
severe_toxic int64
obscene int64
threat int64
insult int64
identity_hate int64
dtype: object
似乎数据类型保持不变。但是,例如,如果我在一系列影片上使用swifter
选项,
data['toxic']=data['toxic'].swifter.apply(np.uint8)
我们得到以下输出;
data.dtypes
id object
comment_text object
toxic uint8
severe_toxic int64
obscene int64
threat int64
insult int64
identity_hate int64
dtype: object
似乎swifter
适用于该系列,但不适用于数据框。我也可以就如何针对数据框架正确修改或编写代码获得一些帮助。预先感谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)