How to group columns by label in a histogram using a panda DataFrame?

Marisa

I have a panda dataframe called language consisting of two columns:

    lang          level
0      english         2
1      spanish         2 
2      spanish         1
3      english         1
4      english         3
5      spanish         2
6      spanish         1
7      spanish         3

I would like to represent it in a histogram group by the categorical value language in such a way that in the same plot I have 2 groups -one for each language- with as many bar as many labels I have in the level column (3 in this case).

So far I have tried the following by previously categorizaing lang getting a label of 1 to english and of 2 to spanish:

language.hist(by=language['lang'])

With what I obtained the following graph which is not what I want.enter image description here

Ideally I would like a graph similar to this where the LetterGrade would be language and the legend would refer to the level variable.enter image description here

BENY

Using :

pd.crosstab(df.lang,df.level).plot(kind='bar')

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Creating a new column in panda dataframe using logical indexing and group by

From Dev

how to add columns label on a Pandas DataFrame

From Dev

How to filter pandas dataframe columns by partial label

From Dev

mean of all the columns of a panda dataframe?

From Dev

Converting list in panda dataframe into columns

From Dev

How to Read Text file as input and write into excel columns using panda?

From Dev

dataframe.plot histogram change label

From Dev

How to group a column in a csv file by a range and plot histogram using python?

From Dev

How to flatten Nested Excel data using Panda or Spark Dataframe?

From Dev

How to flatten Nested Excel data using Panda or Spark Dataframe?

From Dev

How to slice/chop a string using multiple indexes in a panda DataFrame

From Dev

Pandas - How to group sub columns of a dataframe?

From Dev

How to choose a group of columns in a Dask Dataframe?

From Dev

Using Crossfilter to Filter and Group for Histogram

From Dev

Group over Series of lists in Panda Dataframe

From Dev

Python: logical comparing with columns in panda's dataframe

From Dev

tPlotting scatter_matrix with selected columns from panda dataframe using scatter_matrix(dataset)

From Dev

How to Label encode multiple non-contiguous dataframe columns

From Dev

Plotting histogram using seaborn for a dataframe

From Dev

Setting axis label and histogram labels using GNUplot

From Dev

How to explode the column value without duplicating the other columns values in panda dataframe?

From Dev

Histogram of a label

From Dev

How to label data index with count using 3D histogram in Matlab

From Dev

how to group by multiple columns using linq

From Dev

How to group values of columns using PHP MySQL?

From Dev

how to group by multiple columns using linq

From Dev

How to group values of columns using PHP MySQL?

From Dev

using Python, How to group a column in Dataframe by the hour?

From Dev

How to group a DataFrame using labels and sum them?

Related Related

  1. 1

    Creating a new column in panda dataframe using logical indexing and group by

  2. 2

    how to add columns label on a Pandas DataFrame

  3. 3

    How to filter pandas dataframe columns by partial label

  4. 4

    mean of all the columns of a panda dataframe?

  5. 5

    Converting list in panda dataframe into columns

  6. 6

    How to Read Text file as input and write into excel columns using panda?

  7. 7

    dataframe.plot histogram change label

  8. 8

    How to group a column in a csv file by a range and plot histogram using python?

  9. 9

    How to flatten Nested Excel data using Panda or Spark Dataframe?

  10. 10

    How to flatten Nested Excel data using Panda or Spark Dataframe?

  11. 11

    How to slice/chop a string using multiple indexes in a panda DataFrame

  12. 12

    Pandas - How to group sub columns of a dataframe?

  13. 13

    How to choose a group of columns in a Dask Dataframe?

  14. 14

    Using Crossfilter to Filter and Group for Histogram

  15. 15

    Group over Series of lists in Panda Dataframe

  16. 16

    Python: logical comparing with columns in panda's dataframe

  17. 17

    tPlotting scatter_matrix with selected columns from panda dataframe using scatter_matrix(dataset)

  18. 18

    How to Label encode multiple non-contiguous dataframe columns

  19. 19

    Plotting histogram using seaborn for a dataframe

  20. 20

    Setting axis label and histogram labels using GNUplot

  21. 21

    How to explode the column value without duplicating the other columns values in panda dataframe?

  22. 22

    Histogram of a label

  23. 23

    How to label data index with count using 3D histogram in Matlab

  24. 24

    how to group by multiple columns using linq

  25. 25

    How to group values of columns using PHP MySQL?

  26. 26

    how to group by multiple columns using linq

  27. 27

    How to group values of columns using PHP MySQL?

  28. 28

    using Python, How to group a column in Dataframe by the hour?

  29. 29

    How to group a DataFrame using labels and sum them?

HotTag

Archive