0% found this document useful (0 votes)
6 views2 pages

Histogram of Age Groups in Python

The document outlines a Python program aimed at creating a histogram of an age column from a dataset. It details the algorithm, including steps to import data using pandas and visualize it with matplotlib and seaborn libraries. The program successfully categorizes age into groups and displays a histogram and boxplot based on health status.

Uploaded by

vunhsiv47
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Histogram of Age Groups in Python

The document outlines a Python program aimed at creating a histogram of an age column from a dataset. It details the algorithm, including steps to import data using pandas and visualize it with matplotlib and seaborn libraries. The program successfully categorizes age into groups and displays a histogram and boxplot based on health status.

Uploaded by

vunhsiv47
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

710722205049 SRIHARI S

[Link].3
Creating Histogram

Aim
To write a python program to create histogram of age column.

Algorithm
STEP 1: Start the program.
STEP 2: Import the dataset using pandas.
STEP 3: Create the histogram using matplotlib library.
STEP 4: Create the bar chart using season by using seaborn library.
STEP 5: Stop the program.
Program
import pandas as pd
import [Link] as plt
import seaborn as sns

data = pd.read_csv('[Link]')

age_bins = [0, 20, 30, 40, 50, 60, 100]


age_labels = ['<20', '20-29', '30-39', '40-49', '50-59', '60+']
data['AgeGroup'] = [Link](data['Age'], bins=age_bins, labels=age_labels)

[Link](figsize=(10, 6))
[Link](data=data, x='AgeGroup', hue='Health', multiple='dodge', shrink=0.8)
[Link]('Histogram of Age Groups vs Health Status')
[Link]('Age Group')
[Link]('Count')
[Link]()

[Link](figsize=(10, 6))
[Link](data=data, x='AgeGroup', y='Age', hue='Health')

22UCB906/EXPLORATORY DATA ANALYSIS


710722205049 SRIHARI S

Output:

Result
Thus, the python program to create histogram of age column is executed and verified successfully.

22UCB906/EXPLORATORY DATA ANALYSIS

You might also like