Spaces:
Sleeping
Sleeping
File size: 1,376 Bytes
0c046ae 834c9df 0c046ae 834c9df bf0a0b6 0c046ae bf0a0b6 834c9df bf0a0b6 834c9df bf0a0b6 834c9df bf0a0b6 834c9df 4aa9bbb f84d160 4aa9bbb f84d160 bf0a0b6 f84d160 834c9df bf0a0b6 834c9df bf0a0b6 f84d160 bf0a0b6 834c9df 0c046ae 834c9df bf0a0b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
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() |