xiddiqui's picture
updated app.py file, updated graphs
4aa9bbb
from datasets import load_dataset
import gradio as gr
import pandas as pd
import plotly.express as px
# Load dataset
ds = load_dataset("egecandrsn/weatherdata")
df = pd.DataFrame(ds['train'])
df['datetime'] = pd.to_datetime(df['datetime'])
# Create Graphs
def create_graphs():
# Temperature over Time
fig_temp = px.line(df, x='datetime', y='temp', title='Temperature Over Time')
# Precipitation over Time
fig_precip = px.line(df, x='datetime', y='precip', title='Precipitation Over Time')
# Wind Speed over Time
fig_wind = px.line(df, x='datetime', y='windspeed', title='Wind Speed Over Time')
df['year'] = df['datetime'].dt.year
df['heat_index'] = df['temp'] + (0.55 - 0.55 * df['humidity'] / 100) * (df['temp'] - 58)
fig_heat = px.line(df.groupby('year')['heat_index'].mean().reset_index(), x='year', y='heat_index', title='Heat Index Over the Years')
# Return multiple graphs
return fig_temp, fig_precip, fig_wind, fig_heat
# Create Gradio interface
interface = gr.Interface(
fn=create_graphs,
inputs=None, # No input required, as we are just displaying graphs
outputs=[gr.Plot(), gr.Plot(), gr.Plot(), gr.Plot()], # Multiple graph outputs
title="Weather Data Analysis",
description="This app shows multiple weather analysis graphs based on the dataset."
)
# Launch the interface
interface.launch()