如何将一个大的数字转换成一个数字较少的数字?

2024-06-28 20:22:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法将数据转换为十亿单位。现在,我的数据由整数组成,例如12000000000。我希望它的单位是120亿。现在,我不想说10亿,我只想数字变成12。你知道吗

wb = UpdateWorkbook(r'C:\Users\vince\Project\Spreadsheet.xlsx', worksheet=1)
df_2 = fd_frames['income_statement']
a = df_2.values[0].astype('int64') #This is where I get the error
b = a/(1000000000)  #This is what I was thinking of doing, but it doesn't work
wb['M6:T6'] = df_2.values[0] #
wb.save()

每当我试图将列表转换为整数时,总是会出现乘法错误,以下是其中一些错误:

 ValueError: invalid literal for int() with base 10: 'Revenue'
 OverflowError: Python int too large to convert to C long

我认为我最大的麻烦是第一个错误,因为我的列表中有一个单词,而其他的都是数字或值。你知道吗


Tags: to数据df列表is错误单位数字