1

Here is what I'm trying to do: I currently have the below plot

x=frequencia['Numero']
y=frequencia['Recorrencia']
plt.bar(x,y)

I'm trying to plot the first 10 highest values. For that, I can sort my DataFrame with

frequencia.sort_values(by=['Recorrencia'], inplace=True, ascending=False)

But if I try to print the first 10 values using .head(10), all I get is this second plot.

enter image description here

Is there a way to plot it like below instead?

enter image description here

1 Answer 1

1

Try: frequencia = frequencia.sort_values(by=['Recorrencia'])

Then extract the x, y variables to be plotted:

x=frequencia['Numero']
y=frequencia['Recorrencia']
plt.bar(x,y)
Sign up to request clarification or add additional context in comments.

1 Comment

Just figured it out. It wasn't plotting properly because the dtype was int. I changed it to str and if ran without issues.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.