import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Load the dataset
data = pd.read_csv('age and Sex.csv')
# Reshape the dataset from wide to long format
data_long = pd.melt(data, id_vars=['Payer', 'Service', 'Age Group', 'Sex'],
var_name='Year', value_name='Utilization')
# Convert the 'Year' column to numeric for plotting
data_long['Year'] = data_long['Year'].astype(int)
plt.figure(figsize=(12, 6))
sns.lineplot(x='Year', y='Utilization', hue='Age Group', data=data_long)
plt.title("Healthcare Service Utilization Over Time by Age Group")
plt.xlabel("Year")
plt.ylabel("Service Utilization")
plt.legend(title="Age Group")
# Set x-axis ticks to be integers
plt.xticks(data_long['Year'].unique())
plt.show()