1

I have a data like this:

    marital-status      age
0   Never-married       25
1   Married-civ-spouse  38
2   Married-civ-spouse  28
3   Married-civ-spouse  44
4   Never-married       18
5   Never-married       34
6   Never-married       29
7   Married-civ-spouse  63
8   Never-married       24
9   Married-civ-spouse  55
10  Married-civ-spouse  65
11  Married-civ-spouse  36
12  Never-married       26
13  Married-civ-spouse  58
14  Married-civ-spouse  48
15  Married-civ-spouse  43
16  Never-married       20
17  Married-civ-spouse  43
18  Widowed             37
19  Married-civ-spouse  40
20  Married-civ-spouse  34
21  Never-married       34
22  Divorced            72
23  Never-married       25
24  Married-civ-spouse  25

I want to plot histogram of ages for every category in martial-status column. I've tried this:

df['marital-status'].hist(by=df['age']);

But the result is not readable at allresult:

How can I make it readable?

1 Answer 1

1

Maybe swapping age and marital-status in your command:

df['age'].hist(by=df['marital-status']);

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

That's right! but it's still not good enough. is there a way so i can make it biger? i've tried plt.figure(figsize=(16,6)) but it didn't work!
Pass figsize=(16,6) directly: hist(by=df['marital-status'], figsize=(16,6)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.