【问题标题】:Python - How to import strings of numbers with 0 in front [duplicate]Python - 如何导入前面有0的数字字符串[重复]
【发布时间】:2019-06-12 23:56:38
【问题描述】:

我正在使用 pandas 从 excel 中导入数据。我的数据框的一列包含一些以 0 作为第一个字符的数字字符串,python 将其转换为整数。比如 0700 放在 700 上。如何不改变值,将其视为前面有 0 的字符串?

【问题讨论】:

标签: python string pandas dataframe integer


【解决方案1】:

通过在数据框语句中使用“转换器”参数,例如

df = pd.read_excel('*workbook name here',sheetname='*sheet name here',header=0,converters={'*integer column name here':str})

【讨论】:

    猜你喜欢
    • 2010-12-05
    • 2019-01-17
    • 1970-01-01
    • 2015-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多