0% found this document useful (0 votes)
3 views1 page

Code PDF

The document outlines a Python analysis of natural gas price trends, including data loading and preprocessing steps. It features visualizations such as a line plot of overall price trends, monthly average prices, and yearly average prices. The analysis aims to identify patterns and trends in natural gas pricing over time.

Uploaded by

prywvjjq9m
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Code PDF

The document outlines a Python analysis of natural gas price trends, including data loading and preprocessing steps. It features visualizations such as a line plot of overall price trends, monthly average prices, and yearly average prices. The analysis aims to identify patterns and trends in natural gas pricing over time.

Uploaded by

prywvjjq9m
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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]()

You might also like