import pandas as pd
import matplotlib
matplotlib.use('TkAgg')  # Set the backend
import matplotlib.pyplot as plt


# Load the CSV file
df = pd.read_csv('/Users/yasaminbayrami/Documents/name/baby_names_analysis.csv')

# Analyze the popularity of a specific name over the years
def analyze_name(name):
    name_df = df[df['Name'] == name]
    if len(name_df) == 0:
        print("Name not found in the dataset.")
        return

    # Group the data by year and calculate the total count for the name
    name_year_df = name_df.groupby('Year')['Count'].sum()

    # Plot the popularity trend
    plt.plot(name_year_df.index, name_year_df.values)
    plt.title(f"Popularity of the name '{name}' over the years")
    plt.xlabel('Year')
    plt.ylabel('Total Count')
    plt.show()

# Example usage
analyze_name('JASMINE')
