File size: 2,720 Bytes
db8bb75
 
ea9f837
db8bb75
c9ef176
db8bb75
 
c9ef176
 
 
 
 
 
 
 
 
db8bb75
 
 
c9ef176
db8bb75
 
e40733b
c9ef176
 
e40733b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
db8bb75
e40733b
db8bb75
e40733b
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
41
42
43
44
45
46
47
48
49
50
51
import gradio as gr
import pandas as pd
import plotly.express as px

# Function to get exam data
def get_exam_data():
    exams = [
        {"Exam Name": "Junior Engineer (Civil, Mechanical, Electrical and Quantity Surveying & Contracts) Examination, 2024", "Exam Date": "2024-06-05", "Details": "Paper-I (CBE)*"},
        {"Exam Name": "Selection Post Examination, Phase-XII, 2024", "Exam Date": "2024-06-20", "Details": "Phase-XII, 2024"},
        {"Exam Name": "Sub-Inspector in Delhi Police and Central Armed Police Forces Examination, 2024", "Exam Date": "2024-06-27", "Details": "Paper-I (CBE)*"},
        {"Exam Name": "Combined Higher Secondary (10+2) Level Examination, 2024", "Exam Date": "2024-07-01", "Details": "Tier-I (CBE)*"},
        {"Exam Name": "Combined Graduate Level Examination, 2024", "Exam Date": "2024-09-01", "Details": "Tier-I (CBE)*"},
        {"Exam Name": "Multi Tasking (Non-Technical) Staff, and Havaldar (CBIC & CBN) Examination-2024", "Exam Date": "2024-10-01", "Details": "CBE*"},
        {"Exam Name": "Stenographer Grade ‘C’ & ‘D’ Examination, 2024", "Exam Date": "2024-10-15", "Details": "CBE*"},
        {"Exam Name": "Junior Hindi Translator, Junior Translator and Senior Hindi Translator Examination, 2024", "Exam Date": "2024-10-25", "Details": "Paper-I (CBE)*"},
        {"Exam Name": "Constables (GD) in Central Armed Police Forces (CAPFs), NIA, SSF and Rifleman (GD) in Assam Rifles Examination, 2025", "Exam Date": "2025-01-15", "Details": "CBE*"},
    ]
    
    df = pd.DataFrame(exams)
    df['Exam Date'] = pd.to_datetime(df['Exam Date'])
    return df

# Load exam data
df = get_exam_data()

# Function to filter exams by month and generate plot
def filter_exams(month_year):
    filtered_df = df[df['Exam Date'].dt.strftime('%B %Y') == month_year]
    if not filtered_df.empty:
        fig = px.timeline(filtered_df, x_start="Exam Date", x_end="Exam Date", y="Exam Name", color="Exam Name", hover_data=["Details"])
        fig.update_layout(xaxis_title="Date", yaxis_title="Exam")
        return fig, f"Exams scheduled for {month_year}"
    else:
        return None, f"No exams scheduled for {month_year}"

# List of unique months in the dataset
months = df['Exam Date'].dt.strftime('%B %Y').unique().tolist()

# Gradio Interface
with gr.Blocks() as demo:
    gr.Markdown("# Indian Government Exams Calendar")
    month_dropdown = gr.Dropdown(choices=months, label="Select Month")
    plot_output = gr.Plot(label="Exam Timeline")
    text_output = gr.Textbox(label="Exam Details")
    
    month_dropdown.change(fn=filter_exams, inputs=month_dropdown, outputs=[plot_output, text_output])

# Launch the Gradio app
if __name__ == "__main__":
    demo.launch()