2 回答
TA贡献1806条经验 获得超5个赞
像这样的东西会起作用:
In [601]: def thousand_separator(val):
...: return f"{val:,}"
...:
In [602]: df['Company Profit'] = df['Company Profit'].apply(thousand_separator)
In [603]: df['Company Profit']
Out[602]:
0 33,536,310
1 842,925,200
Name: Profit, dtype: object
TA贡献1834条经验 获得超8个赞
或者,您可以f-string在较新版本的 Python 中执行此操作。使用逗号作为分隔符:
df = pd.DataFrame({'Company Profit':[33536310,842925200,231535366]})
df['Company Profit'] = df['Company Profit'].apply(lambda x: f"{x:,}")
print(df)
Company Profit
0 33,536,310
1 842,925,200
2 231,535,366
添加回答
举报