ANALYSIS OF NATURAL GAS PRICE TRENDS USING PYTHON
# --- Data Loading and Preprocessing ---
import pandas as pd
import [Link] as plt
df • pd. read_csv( 'natura~_gas_prices .csv')
df[ 'Date•] = pd. to_datet1me(df[ 'Date'])
df = df. sort_values( •Date')
df['Month'] = df('Date'[Link]
df['Year'] = df[ Date'].[Link]
# --- 1. Line Plot (Overall Trend)
plt. figure()
plt .plot(df[ 'Date']. df[ 'Price'])
plt. title(• Natural Gas Pr ices over Time')
plt .xlabel( 'Date')
plt .ylabel( 'Price•)
pl t. xticks( rotation•45)
pl t. tight layout()
[Link](j"
# --- 2. Monthly Seasonality ---
monthly_avg = df .groupby( 'Month')[• Price'] .mean()
plt. figure()
plt .plot(monthly_avg. index, monthly_avg. values, marker• 'o')
plt. title( 'Average Monthly Natural Gas Prices')
plt .xlabel( 'Montfl')
[Link]( 'Average Price')
[Link](range(1, 13))
[Link]()
[Link]()
# --- 3. Yearly Trend ---
yearly_avg • [Link]('Year')['Price'].mean()
plt. figure()
[Link](yearly [Link], yearly_avg.values, marker='o')
[Link]('Year!y Average Natural Gas Prices')
[Link]( 'Year•)
plt .ylabel( 'Average Price')
[Link]()
[Link]()