Analysing US State Temperature Trends Using GenAI: A No-Code Approach for Researchers

Analysing US State Temperature Trends Using GenAI: A No-Code Approach for Researchers
Source: Freepik - armmypicca

Time series analysis is a powerful tool for researchers across disciplines, yet its reliance on programming can pose a challenge for those without coding expertise. This blog demonstrates how AI-driven prompts can enable researchers to perform simple time series analyses without writing a single line of code, making data insights more accessible.

Using a dataset of US state temperatures as a case study, we visualised smoothed annual temperature trends to identify long-term patterns. We then created a heatmap to compare average temperatures across states. Finally, we analysed temperature changes between 2015–2019 and 2020–2024 to uncover recent shifts, all through a series of concise, actionable prompts tested using GPT-4.5.

Input file

The data was sourced from the NOAA Climate at a Glance, from which individual state-level time series were downloaded and merged into a single combined .xlsx file. The input file, us_climate_combined.xlsx, contained a dataset of monthly records for US states spanning from January 2005 to December 2024, with columns for Date, Year, Value, and State. For this analysis, we focused on a subset of the data from 2015 to 2024, covering 50 states with 120 entries each (10 years × 12 months), to explore temporal trends and changes.

Prompt 1: Data Preparation

Load the Excel file 'us_climate_combined.xlsx' containing columns 'Date', 'Year', 'Value', and 'State', where 'Value' represents monthly temperature data in degrees Fahrenheit.

Convert the 'Date' column to a datetime format to enable time-based operations.

Keep the temperature values in Fahrenheit, as this is the unit used in the dataset and preferred for U.S.-based analysis.

Filter the dataset to include only data from January 2015 to December 2024 by selecting rows where the year in the 'Date' column is between 2015 and 2024 (inclusive).

Check for missing values in the 'Value' column and fill them using a forward-fill method (i.e., replace missing values with the last valid observation).

Confirm the date range of the filtered dataset by outputting the earliest and latest dates present in the 'Date' column, ensuring the data covers the period from January 2015 to December 2024.

Group the data by 'State' and count the number of entries per state to confirm consistency (e.g., each state should have 120 entries for 10 years of monthly data from 2015 to 2024).

Output a summary table showing the number of entries per state and note any adjustments made (e.g., how many missing values were filled, and confirm that temperatures remain in Fahrenheit).

Output 1

GPT-4.5's performance (accessed on 26 March 2025)

The model successfully read the dataset from us_climate_combined.xlsx, accurately filtering it to cover the period from January 2015 to December 2024, as confirmed by the reported date range. It also thoroughly checked the database, verifying the absence of missing values in the Value column and ensuring that each state had the expected 120 entries for the 10-year period. Additionally, the model preserved the temperature unit in Fahrenheit, aligning with the prompt’s requirements.

Prompt 2: Calculate Annual Averages per State

Using the filtered dataset from the previous step (with temperatures in Fahrenheit, covering 2015–2024), calculate the annual average temperature for each state from 2015 to 2024.

Group the data by 'Year' and 'State', then compute the mean of the 'Value' column for each group to get the annual average temperature in Fahrenheit.

Store the result in a table with columns 'Year', 'State', and 'Annual_Average_Temperature'.

Verify that each state has exactly 10 years of data (2015–2024) and report any anomalies (e.g., missing years for any state).

Output the first 5 rows of this table to confirm the calculation, ensuring the temperatures are in degrees Fahrenheit.

Output 2

GPT-4.5's performance (accessed on 26 March 2025)

The model accurately processed the second prompt by grouping the filtered dataset by year and state, calculating the annual average temperatures in Fahrenheit, and presenting the first five rows of the resulting table for 2015 across states like Alabama, Alaska and Arizona.

It also verified that each state had exactly 10 years of data (2015–2024) with no anomalies, ensuring the dataset’s completeness for the analysis. This step demonstrated the model’s ability to handle data aggregation and validation tasks effectively, aligning with the prompt’s requirements.

Prompt 3: Visualisation 1 - Smoothed Trend Lines for Selected States

Create a line graph to visualise the smoothed annual average temperature trends from 2015 to 2024 for three climatically diverse states: Florida (very warm), Kansas (average), and Alaska (very cold).

Use the annual averages table from the previous step (with temperatures in Fahrenheit, covering 2015–2024), with 'Year' on the x-axis and 'Annual_Average_Temperature' on the y-axis.

For each state, calculate a 3-year centered rolling average of the annual temperatures to smooth the trend, and plot this smoothed line.

Use distinct colours for each state: Florida in orange, Kansas in green, and Alaska in blue. Set the line width to 2 for clarity. Include a legend in the top-right corner labelled 'State' with a font size of 10 and title font size of 12. Set the title to 'Smoothed Annual Average Temperature Trends (2015–2024)' with a font size of 14 and padding of 20. Label the x-axis as 'Year' and the y-axis as 'Temperature (°F)', both with a font size of 12. Add a grid with a dashed style and 70% opacity.

Ensure the x-axis ticks range from 2015 to 2024 in increments of 1 year (e.g., 2015, 2016, ..., 2024). Set the figure size to 12 inches wide and 6 inches tall. The graph should clearly show the smoothed temperature trends across these states, with temperatures in Fahrenheit.

Output 3

GPT-4.5's performance (accessed on 26 March 2025)

The model effectively executed the third prompt by generating a line graph that visualised the smoothed annual temperature trends for Florida, Kansas, and Alaska from 2015 to 2024, using the specified colours and a 3-year centered rolling average. It accurately incorporated all requested elements, including the full date range, a dashed grid, and a legend with climate descriptions, while ensuring temperatures were displayed in Fahrenheit.

Prompt 4: Visualisation 2 - Heatmap of Monthly Average Temperatures Across States

Create a heatmap to visualise the average monthly temperature for each state from 2015 to 2024. Using the filtered dataset (covering 2015–2024), add a 'Month' column by extracting the month from the 'Date' column.

Calculate the monthly average temperature for each state by grouping the data by 'Year', 'Month', and 'State', and computing the mean of the 'Value' column.

Then, compute the average temperature for each state and month across all years (2015–2024) by grouping by 'State' and 'Month'.

Create a matrix where rows are states, columns are months (1 to 12), and the values are the average temperatures in Fahrenheit.

Sort the states by their overall average annual temperature (from coldest to warmest) to order the rows of the heatmap.

Generate a heatmap using the 'RdYlBu_r' colour gradient, which transitions smoothly from red (for the highest temperatures, e.g., around 70°F and above), through yellow (for moderate temperatures, e.g., around 50°F), to blue (for the lowest temperatures, e.g., around 30°F and below).

Add annotations showing the temperature values rounded to 1 decimal place. Include a colour bar with the label 'Temperature (°F)'. Set the title to 'Average Monthly Temperature by State (2015–2024)' with a font size of 14 and padding of 20. Label the x-axis as 'Month' and the y-axis as 'State', both with a font size of 12.

Set the x-axis ticks to range from 1 to 12, with labels 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'. Set the figure size to 12 inches wide and 10 inches tall. This heatmap should visually highlight temperature differences across states, with the colour gradient clearly indicating warmer (red) to cooler (blue) temperatures, all in Fahrenheit.

Output 4

GPT-4.5's performance (accessed on 26 March 2025)

For the fourth prompt, the model produced a heatmap that closely resembled a visualisation one would expect from a well-crafted data science script—accurately depicting average monthly temperatures across US states from 2015 to 2024. It maintained key features such as the reversed RdYlBu colour scale, sorted state ordering, and precise annotations.

Prompt 5: Visualisation 3 - Temperature Change Between 2015–2019 and 2020–2024

Calculate and visualise the change in average annual temperature for each state between the periods 2015–2019 and 2020–2024. Using the annual averages table from Prompt 2 (with temperatures in Fahrenheit, covering 2015–2024), split the data into two periods: 2015–2019 (first 5 years) and 2020–2024 (last 5 years).

For each state, calculate the average annual temperature for 2015–2019 by taking the mean of the 'Annual_Average_Temperature' column for those years, and do the same for 2020–2024.

Compute the temperature change for each state by subtracting the 2015–2019 average from the 2020–2024 average. Store the result in a table with columns 'State', 'Avg_Temp_2015_2019', 'Avg_Temp_2020_2024', and 'Temp_Change'.

Sort the table by 'Temp_Change' in descending order to highlight states with the largest temperature increases. Output the first 15 rows of this table to show the states with the highest temperature increases.

Create a bar plot to visualise the temperature change for each state, with 'State' on the y-axis and 'Temp_Change' on the x-axis.

Use the 'RdYlBu_r' colour palette to colour the bars, where positive changes (increases) are shaded red, negative changes (decreases) are shaded blue, and near-zero changes are shaded yellow. Add a vertical line at x=0 with a black dashed style and 50% opacity to indicate the zero-change level. Set the title to 'Temperature Change Between 2015–2019 and 2020–2024' with a font size of 14 and padding of 20. Label the x-axis as 'Temperature Change (°F)' and the y-axis as 'State', both with a font size of 12. Set the figure size to 12 inches wide and 10 inches tall.

This plot should clearly show which states have experienced the largest temperature increases or decreases between the two periods, with temperatures in Fahrenheit.

Output 5

GPT-4.5's performance (accessed on 26 March 2025)
GPT-4.5's performance (accessed on 26 March 2025)

The model reproduced a bar plot, capturing temperature changes across US states between 2015–2019 and 2020–2024. The output included the reversed RdYlBu colour scheme and an accompanying table showcasing the top 15 states.

Prompt 6: Validation of Temperature Change for Selected States

Validate the temperature change results for Florida, Kansas, and Alaska by calculating and confirming the average temperatures for the periods 2015–2019 and 2020–2024. Using the table from Prompt 5 (with columns 'State', 'Avg_Temp_2015_2019', 'Avg_Temp_2020_2024', and 'Temp_Change'), extract the data for Florida, Kansas, and Alaska.

For each state, output the average temperature for 2015–2019, the average temperature for 2020–2024, and the temperature change between the two periods.

Specifically, check if Alaska’s average temperature decreased by more than 2°F between 2015–2019 and 2020–2024, and output a message indicating whether this condition is met (e.g., 'Alaska’s average temperature decreased by more than 2°F' or 'Alaska’s average temperature did not decrease by more than 2°F').

Present the results in a clear summary, ensuring all temperatures are in Fahrenheit.

The final validation prompt served to cross-check the temperature change results for Florida, Kansas, and Alaska, ensuring the accuracy of the earlier analysis by recalculating and confirming the period averages and changes.

Output 6

GPT-4.5's performance (accessed on 26 March 2025)

In response to the sixth prompt, the AI model produced a clear and structured summary table confirming temperature variations in Florida, Kansas, and Alaska—accurately reflecting Alaska’s notable decrease of over 2°F between the 2015–2019 and 2020–2024 periods.

Script

Those wishing to verify the results can execute the script below, which reproduces the same visualisation generated by the GenAI model in response to the prompt. The identical output confirms that the model's response is analytically consistent with a conventional Python-based implementation.

Source: Authors' own

Recommendation

This demonstration highlights that prompt-based approaches can effectively support basic data analysis workflows, including time series visualisation and trend validation. GenAI tools like GPT-4.5 offer accessible alternatives to code-heavy methods, particularly for users with limited programming experience. However, we strongly advise using these models with appropriate supervision. While suitable for certain structured tasks—such as data cleaning, exploratory visualisation, or simple natural language processing—GenAI should not be relied upon in methodological contexts where the user lacks sufficient expertise to verify outputs independently.

The authors used GPT-4.5 [OpenAI (2025), GPT-4.5 (accessed on 26 March 2025), Large language model (LLM), available at: https://openai.com] to generate the output.