This Python script analyzes teacher salaries across different states by retrieving data from a Google Sheets dataset. It provides users with a menu to explore salary rankings, cost-of-living-adjusted salaries, average salary calculations, and the correlation between salaries and cost of living. The program runs in a loop, allowing users to select different analysis options until they choose to exit.
The script retrieves teacher salary and cost of living data from a Google Sheets dataset, processes it into dictionaries, and provides an interactive menu for users to analyze the data. It allows users to view the highest and lowest salaries, calculate cost-of-living-adjusted salaries, determine the average salary, and compute the correlation between salaries and cost of living. The program runs in a loop until the user chooses to exit, ensuring continuous access to data insights.
The expected output of this script is an interactive menu that allows users to analyze teacher salaries across states. Depending on the selected option, the script will display the highest and lowest salaries, cost-of-living-adjusted salaries, the average salary, or the correlation between salaries and cost of living. The program will continue running in a loop until the user selects the exit option.
data_teacher- A string containing the URL of the Google Sheets dataset in CSV format.
d_teacher: A pandas DataFrame that loads the dataset from the CSV URL.
teacher_salaries: A dictionary mapping each state to its average teacher salary.
cost_of_living_index: A dictionary mapping each state to its cost of living index.
adjusted_salaries: A dictionary that stores the cost-of-living-adjusted salaries for each state.
highest: A variable used to store the state with the highest salary (or adjusted salary).
lowest: A variable used to store the state with the lowest salary (or adjusted salary).
avg_salary: A float representing the average teacher salary across all states.
salaries: A list of teacher salaries extracted from the teacher_salaries dictionary.
cost_index: A list of cost-of-living values extracted from the cost_of_living_index dictionary.
correlation: A float representing the correlation coefficient between teacher salaries and cost of living.
choice: An integer representing the user’s menu selection for different analysis options.
Python Script Using Loops