Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

444
Vistas
pandas plot value counts barplot in descending manner

I have a dataframe where i am trying to count the occurrence of each value. I plot it as horizontal bar but cant get it to be sorted.

df = pd.DataFrame(['A','A','A','B','B','C'],columns = ['letters'])

df.value_counts()

A 3
B 2
C 1

enter image description here

How can i get it sorted in a descending manner?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You can do it by changing your plotting line like this

df.letters.value_counts().sort_values().plot(kind = 'barh')
over 4 years ago · Santiago Trujillo Denunciar

0

This might count as a bit of a hack, but try this:

df.letters.value_counts().sort_index(ascending=False).plot(kind='barh')
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda