Zeichnen Sie ein Balkendiagramm in python mit Matplotlib.pyplot

   Groups   Counts
1   0-9     38
3   10-19   41
5   20-29   77
7   30-39   73
9   40-49   34

Ich möchte erstellen Sie ein Balkendiagramm mit matplotlib.pyplot Bibliothek mit Gruppen auf der x-Achse und Zählt auf der y-Achse. Ich versuchte es mit folgenden code

    ax = plt.subplots()
    rects1 = ax.bar(survived_df["Groups"], survived_df["Counts"], color='r')
    plt.show()

aber ich bin immer folgenden Fehler

   invalid literal for float(): 0-9
offenbar (wie die Fehlermeldung sagt) den Datentyp Spalte groups (Gruppen) ist nicht kompatibel zu einem float. Was ist dein Datentyp? string? welche Art von Objekt ist survived_df. Verwenden Sie Pandas? dann fügen Sie die tags!

InformationsquelleAutor Nagesh Joshi | 2016-10-29

Schreibe einen Kommentar