├── analysis.py ├── weather-csv.csv └── README.md /analysis.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import matplotlib.pyplot as plt 3 | import seaborn as sns 4 | 5 | # Reading the CSV file 6 | file_path = 'weather-csv.csv' # Path to the CSV file 7 | data = pd.read_csv(file_path) 8 | 9 | # Initial data overview 10 | print("Initial Data Information:") 11 | print(data.info()) 12 | print("\nStatistical Summary of Data:") 13 | print(data.describe()) 14 | 15 | # Convert the Date column to datetime type 16 | data['Date'] = pd.to_datetime(data['Date']) 17 | 18 | # Set plot dimensions 19 | plt.figure(figsize=(12, 8)) 20 | 21 | # Plot temperature trends over time 22 | plt.subplot(2, 2, 1) 23 | sns.lineplot(x=data['Date'], y=data['Temperature (°C)'], color='orange') 24 | plt.title("Temperature Trends Over Time") 25 | plt.xlabel("Date") 26 | plt.ylabel("Temperature (°C)") 27 | 28 | # Plot humidity trends over time 29 | plt.subplot(2, 2, 2) 30 | sns.lineplot(x=data['Date'], y=data['Humidity (%)'], color='blue') 31 | plt.title("Humidity Trends Over Time") 32 | plt.xlabel("Date") 33 | plt.ylabel("Humidity (%)") 34 | 35 | # Plot pressure trends over time 36 | plt.subplot(2, 2, 3) 37 | sns.lineplot(x=data['Date'], y=data['Pressure (hPa)'], color='purple') 38 | plt.title("Pressure Trends Over Time") 39 | plt.xlabel("Date") 40 | plt.ylabel("Pressure (hPa)") 41 | 42 | # Plot wind speed trends over time 43 | plt.subplot(2, 2, 4) 44 | sns.lineplot(x=data['Date'], y=data['Wind Speed (km/h)'], color='green') 45 | plt.title("Wind Speed Trends Over Time") 46 | plt.xlabel("Date") 47 | plt.ylabel("Wind Speed (km/h)") 48 | 49 | plt.tight_layout() 50 | plt.show() 51 | 52 | # Updated countplot for weather conditions 53 | plt.figure(figsize=(10, 6)) 54 | sns.countplot(y=data['Weather Condition'], palette='viridis', orient="h", order=data['Weather Condition'].value_counts().index) 55 | plt.title("Frequency of Weather Conditions") 56 | plt.xlabel("Number of Days") 57 | plt.ylabel("Weather Condition") 58 | plt.xticks(rotation=45) 59 | plt.show() 60 | 61 | # Selecting only numeric columns for correlation calculation 62 | numeric_data = data.select_dtypes(include=['float64', 'int64']) 63 | correlation_matrix = numeric_data.corr() 64 | 65 | # Plot the updated correlation matrix 66 | plt.figure(figsize=(10, 8)) 67 | sns.heatmap(correlation_matrix, annot=True, cmap="coolwarm", linewidths=0.5) 68 | plt.title("Correlation Matrix of Factors") 69 | plt.show() -------------------------------------------------------------------------------- /weather-csv.csv: -------------------------------------------------------------------------------- 1 | Date,Temperature (°C),Humidity (%),Wind Speed (km/h),Wind Direction (°),Pressure (hPa),Weather Condition 2 | 2023-01-01,6,75,12,210,1012,Cloudy 3 | 2023-01-02,8,70,14,180,1010,Sunny 4 | 2023-01-03,5,80,10,200,1013,Rainy 5 | 2023-01-04,7,65,8,220,1011,Cloudy 6 | 2023-01-05,9,60,11,190,1009,Sunny 7 | 2023-01-06,4,85,9,230,1014,Rainy 8 | 2023-01-07,6,78,13,210,1012,Cloudy 9 | 2023-01-08,10,65,15,240,1010,Sunny 10 | 2023-01-09,3,90,7,220,1015,Snowy 11 | 2023-01-10,5,80,12,200,1013,Rainy 12 | 2023-01-11,8,72,10,215,1011,Cloudy 13 | 2023-01-12,11,68,14,190,1008,Sunny 14 | 2023-01-13,6,75,9,210,1012,Cloudy 15 | 2023-01-14,7,77,11,205,1010,Partly Cloudy 16 | 2023-01-15,5,82,8,220,1013,Rainy 17 | 2023-01-16,8,70,10,215,1010,Sunny 18 | 2023-01-17,9,65,13,180,1009,Sunny 19 | 2023-01-18,4,88,9,230,1015,Rainy 20 | 2023-01-19,6,75,12,210,1011,Cloudy 21 | 2023-01-20,7,72,14,205,1010,Partly Cloudy 22 | 2023-01-21,3,85,8,240,1014,Snowy 23 | 2023-01-22,5,80,12,200,1013,Rainy 24 | 2023-01-23,10,66,15,190,1008,Sunny 25 | 2023-01-24,6,77,11,215,1012,Cloudy 26 | 2023-01-25,8,68,10,220,1010,Partly Cloudy 27 | 2023-01-26,4,90,9,210,1014,Rainy 28 | 2023-01-27,7,70,13,230,1011,Cloudy 29 | 2023-01-28,9,65,12,205,1009,Sunny 30 | 2023-01-29,5,80,8,240,1015,Rainy 31 | 2023-01-30,8,72,14,180,1010,Partly Cloudy 32 | 2023-02-01,10,60,12,185,1007,Sunny 33 | 2023-02-02,12,55,14,175,1005,Sunny 34 | 2023-02-03,7,78,11,220,1012,Cloudy 35 | 2023-02-04,5,82,9,210,1014,Rainy 36 | 2023-02-05,9,65,10,215,1010,Partly Cloudy 37 | 2023-02-06,6,80,8,225,1015,Rainy 38 | 2023-02-07,8,72,12,205,1011,Cloudy 39 | 2023-02-08,11,68,14,190,1008,Sunny 40 | 2023-02-09,4,85,10,220,1013,Snowy 41 | 2023-02-10,5,79,13,230,1011,Cloudy 42 | 2023-02-11,9,64,9,210,1009,Sunny 43 | 2023-02-12,6,78,12,215,1012,Cloudy 44 | 2023-02-13,8,70,15,225,1013,Partly Cloudy 45 | 2023-02-14,3,90,8,200,1015,Snowy 46 | 2023-02-15,7,74,11,240,1010,Cloudy 47 | 2023-02-16,10,65,13,185,1009,Sunny 48 | 2023-02-17,6,77,9,230,1014,Rainy 49 | 2023-02-18,8,69,10,190,1012,Cloudy 50 | 2023-02-19,12,58,12,180,1006,Sunny 51 | 2023-02-20,11,60,14,175,1008,Partly Cloudy 52 | 2023-02-21,5,82,7,220,1015,Rainy 53 | 2023-02-22,6,78,9,205,1011,Cloudy 54 | 2023-02-23,9,63,15,215,1009,Sunny 55 | 2023-02-24,7,76,12,225,1013,Cloudy 56 | 2023-02-25,8,72,10,230,1012,Partly Cloudy 57 | 2023-02-26,4,88,8,200,1014,Snowy 58 | 2023-02-27,6,75,14,210,1011,Cloudy 59 | 2023-02-28,10,67,13,180,1007,Sunny 60 | 2023-03-01,9,70,11,185,1010,Sunny 61 | 2023-03-02,5,80,10,215,1013,Cloudy 62 | 2023-03-03,6,78,8,210,1012,Rainy 63 | 2023-03-04,8,65,12,190,1009,Sunny 64 | 2023-03-05,11,60,15,180,1006,Sunny 65 | 2023-03-06,7,75,10,225,1014,Cloudy 66 | 2023-03-07,5,80,11,210,1015,Rainy 67 | 2023-03-08,10,68,14,190,1008,Sunny -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🌤️ Tehran Weather Analysis 2 | 3 | A comprehensive **Python-based data analysis** project that explores historical and real-time weather patterns in Tehran. Ideal for understanding climate trends, visualizing seasonal changes, and uncovering meaningful insights from meteorological data. 4 | 5 | --- 6 | 7 | ## 📋 Table of Contents 8 | 9 | 1. [Overview](#overview) 10 | 2. [Objectives](#objectives) 11 | 3. [Dataset](#dataset) 12 | 4. [Tech Stack & Requirements](#tech-stack--requirements) 13 | 5. [Installation & Setup](#installation--setup) 14 | 6. [Analysis Workflow](#analysis-workflow) 15 | 7. [Insights & Visualizations](#insights--visualizations) 16 | 8. [Future Enhancements](#future-enhancements) 17 | 9. [Contributing](#contributing) 18 | 10. [License](#license) 19 | 20 | --- 21 | 22 | ## 💡 Overview 23 | 24 | This project delves into Tehran’s weather data—such as temperature, humidity, precipitation, and wind speed—to explore historical trends, seasonal cycles, and extreme weather events. The goal is to translate raw data into scientific insights and visual stories. 25 | 26 | --- 27 | 28 | ## 🎯 Objectives 29 | 30 | - 📈 Track **long-term trends** (e.g., increasing temperatures or shifting rainfall patterns) 31 | - 📉 Analyze **seasonal cycles** across months and years 32 | - 🌪️ Identify **extreme events**, like heatwaves or heavy rain 33 | - 🔍 Correlate multiple variables to understand interdependencies (e.g., temperature vs humidity) 34 | - 🖼 Create **visual storytelling dashboards** that communicate findings intuitively 35 | 36 | --- 37 | 38 | ## 🗂 Dataset 39 | 40 | Data typically includes: 41 | 42 | - `Date` – Timestamp (daily/hourly) 43 | - `Temperature` (max/min/avg) 44 | - `Humidity`, `Precipitation`, `WindSpeed`, `Pressure`, etc. 45 | 46 | *(Adapt descriptions to match your actual dataset structure.)* 47 | 48 | --- 49 | 50 | ## 🛠 Tech Stack & Requirements 51 | 52 | - **Python 3.7+** 53 | - Libraries: 54 | - `pandas`, `NumPy` – data manipulation 55 | - `matplotlib`, `seaborn` – static visualizations 56 | - Optional: `statsmodels`, `SciPy` for trend modeling 57 | - Optional: `plotly`, `Streamlit` for interactive dashboards 58 | 59 | --- 60 | 61 | ## ⚙️ Installation & Setup 62 | 63 | ```bash 64 | git clone https://github.com/MisaghMomeniB/Tehran-Weather-Analysis.git 65 | cd Tehran-Weather-Analysis 66 | python3 -m venv venv 67 | source venv/bin/activate 68 | pip install -r requirements.txt 69 | ```` 70 | 71 | --- 72 | 73 | ## 📊 Analysis Workflow 74 | 75 | 1. **Data load & cleaning** – handle missing values, convert types, extract date parts 76 | 2. **Exploratory analysis** – visualize day-by-day, month-by-month, and year-by-year trends 77 | 3. **Statistical trend detection** – apply moving averages and regression or seasonal decomposition 78 | 4. **Heatmap visualizations** – e.g., month vs year grids for temperature or rainfall 79 | 5. **Correlation analysis** – explore variable interactions using correlation matrices 80 | 81 | --- 82 | 83 | ## 🎨 Insights & Visualizations 84 | 85 | * Line plots for daily, monthly, and annual temperature trends 86 | * Boxplots of seasonal humidity or temperature variation 87 | * Heatmaps showing seasonal patterns year-over-year 88 | * Correlation matrices highlighting variable inter-dependencies 89 | * Optionally, `reports/` directory contains charts (PNG/HTML) and summary tables 90 | 91 | --- 92 | 93 | ## ⚡ Future Enhancements 94 | 95 | * 📆 **Time‑series forecasting** using ARIMA, Prophet, or LSTM for future weather prediction 96 | * 🌐 Add real-time API integration (e.g., OpenWeatherMap) 97 | * 🧭 Interactive dashboards using Plotly or Streamlit 98 | * 🌍 Compare Tehran trends with other cities 99 | * 📦 Package as a CLI tool or module for reusability 100 | 101 | --- 102 | 103 | ## 🤝 Contributing 104 | 105 | Contributions are welcome! Steps to collaborate: 106 | 107 | 1. Fork this repo 108 | 2. Create a feature branch (`feature/...`) 109 | 3. Add code, docs, or visualizations with clear comments 110 | 4. Submit a Pull Request explaining your additions 111 | 112 | --- 113 | 114 | ## 📄 License 115 | 116 | Released under the **MIT License** — see `LICENSE` for details. 117 | --------------------------------------------------------------------------------