Raymond Surya
Raymond Surya

Reputation: 21

how do i limit an attribute plot

so i have this code

df.plot(kind="bar", x="Countries", y=["2014","2015","2016","2017","2018","2019"], figsize=(50,5), stacked= True, title="Persentase populasi yang terjangkau jaringan seluler")

and this dataenter image description here

if i want to limit the number of the country displayed, for example, the first 20 countries. How to do it?

Upvotes: 0

Views: 23

Answers (1)

karlosos
karlosos

Reputation: 1174

df.iloc[:20].plot(kind="bar", x="Countries", y=["2014","2015","2016","2017","2018","2019"], figsize=(50,5), stacked= True, title="Persentase populasi yang terjangkau jaringan seluler")

With df.iloc[:20] you select first 20 rows from your DataFrame.

Upvotes: 1

Related Questions