Python 如何将图中的指数值转换为Int

Python 如何将图中的指数值转换为Int,python,pandas,numpy,matplotlib,seaborn,Python,Pandas,Numpy,Matplotlib,Seaborn,当我试图为上面的代码创建图形时,它正在转换为指数。我怎样才能防止这种情况发生?没有样本数据,所以我不知道您的数字有多大。使用FuncFormatter()以所需格式生成标签。我已经展示了数十亿 plt.figure(figsize=(28,8)) plt.xticks(rotation=90) a = df2.groupby('Province/State')['Confirmed'].sum().astype('int64') print(a) a.plot(kind = 'bar') 我不

当我试图为上面的代码创建图形时,它正在转换为指数。我怎样才能防止这种情况发生?

没有样本数据,所以我不知道您的数字有多大。使用
FuncFormatter()
以所需格式生成标签。我已经展示了数十亿

plt.figure(figsize=(28,8))
plt.xticks(rotation=90)
a = df2.groupby('Province/State')['Confirmed'].sum().astype('int64')
print(a)
a.plot(kind = 'bar')

我不知道你的数据集的大小。但是你可以试试这个

import matplotlib as mpl
df2=pd.DataFrame({"Province/State":["CA"],"Confirmed":[10**12]})

plt.figure(figsize=(28,8))
plt.xticks(rotation=90)
a = df2.groupby('Province/State')['Confirmed'].sum().astype('int64')
print(a)
ax = a.plot(kind = 'bar')
ax.yaxis.set_major_formatter(mpl.ticker.FuncFormatter(lambda x, p: f"{x//10**9:,.0f}B"))

如果没有完整的运行示例(代码和数据),很难给出建议。我从kaggle获取了这些数据…covid_19_data.csvA应该在您的问题中包含样本数据。另见。
plt.ticklabel_format(useOffset=False,style='plain', axis='y')