1

I'm plotting this dataframe of 1-5 stars and it works fine.

5 4424

4 2177

1 1529

3 1070

2 800

However, i want to sort the indices in ascending order - "1,2,3,4,5", not plot it by the actual values: kk

the code that plots:

j.sort_index(by='stars').plot(kind='bar', rot = 1, figsize=(15,6))

I want the indexes to come in ascending order - 1,2,3,4,5.

3
  • 1
    If change j.sort_index(by='stars') to j.sort_index() how working? Commented Jul 22, 2019 at 11:18
  • @jezrael yay! works! Commented Jul 22, 2019 at 11:18
  • 1
    @jezrael thx u so much!! Commented Jul 22, 2019 at 11:19

1 Answer 1

2

Remove parameter by from sort_index for sorting by default index values:

j.sort_index().plot(kind='bar', rot = 1, figsize=(15,6))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.