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

When I am trying to create graph for above code It's converting into the Exponential. How can I prevent That?

  • 2
    Without complete running example (code and data) it's difficult to give an advice. – pyano Apr 30 '21 at 16:44
  • 1
    I have taken this data from kaggle....covid_19_data.csv – Arvind Kumar Yadav Apr 30 '21 at 16:52
  • 1
    A [reprex] should include sample data in your question. Also see [reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – BigBen Apr 30 '21 at 16:57

2 Answers2

1

I do not know the size of your data set. But you can try this.

plt.ticklabel_format(useOffset=False,style='plain', axis='y')
0

No sample data so I don't know how large your numbers are. Use FuncFormatter() to generate labels in format you want. I've demonstrated billions...

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"))
Rob Raymond
  • 29,118
  • 3
  • 14
  • 30