如何在 Pandas 中将 DataFrame 某列数据类型转换为字符串

您所在的位置:网站首页 series转string 如何在 Pandas 中将 DataFrame 某列数据类型转换为字符串

如何在 Pandas 中将 DataFrame 某列数据类型转换为字符串

#如何在 Pandas 中将 DataFrame 某列数据类型转换为字符串| 来源: 网络整理| 查看: 265

某列转换为字符串:df['BucketType'] = pd.Series(df['BucketType'], dtype="string")df['BucketType'] = pd.Series(df['BucketType'], dtype=pd.StringDtype())df['BucketType'] = df['BucketType'].astype("string")

将某列改为字符串:df['A'] = df['A'].astype(str)将某列改为字符串:df[['B']] = df[['B']].astype(str)把多列改为字符串:df[['A','B']] = df[['A','B']].astype(str)将某列改为字符串:df['A'] = df['A'].apply(lambda _: str(_))

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3