Python-如何导入前面带有0的数字字符串

时间:2019-01-18 17:20:23

标签: python string pandas dataframe integer

我正在使用熊猫从excel导入数据。我数据框的一列包含一些数字字符串,其中第一个字符为0,而python将其转换为整数。例如0700放置在700。如何不更改值并将其视为前面带有0的字符串?

1 个答案:

答案 0 :(得分:0)

例如,在数据框语句中使用“ converters”参数

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