Delete evtracker.py
Browse files- evtracker.py +0 -47
evtracker.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
import pandas as pd
|
| 2 |
-
import gradio as gr
|
| 3 |
-
|
| 4 |
-
# 1. The Database (Hardcoded directly, no CSV needed!)
|
| 5 |
-
ev_data = {
|
| 6 |
-
"Model": ["Bounce Infinity E1", "TVS iQube", "Bajaj Chetak", "Ather 450X", "Ola S1 Pro", "Hero Vida V1"],
|
| 7 |
-
"Price (INR)": [79000, 123000, 122000, 138000, 147000, 145000],
|
| 8 |
-
"Real Range (km)": [85, 100, 90, 105, 143, 110],
|
| 9 |
-
"Top Speed (kmph)": [65, 78, 73, 90, 120, 80],
|
| 10 |
-
"Charging Time (Hrs)": [4.0, 4.5, 4.0, 5.5, 6.5, 6.0]
|
| 11 |
-
}
|
| 12 |
-
df = pd.DataFrame(ev_data)
|
| 13 |
-
|
| 14 |
-
# 2. The Search Logic
|
| 15 |
-
def recommend_ev(max_budget, min_range):
|
| 16 |
-
# Filter the dataframe based on user slider inputs
|
| 17 |
-
filtered_df = df[(df["Price (INR)"] <= max_budget) & (df["Real Range (km)"] >= min_range)]
|
| 18 |
-
|
| 19 |
-
# Sort the results so the cheapest options appear at the top
|
| 20 |
-
filtered_df = filtered_df.sort_values(by="Price (INR)")
|
| 21 |
-
|
| 22 |
-
return filtered_df
|
| 23 |
-
|
| 24 |
-
# 3. The Frontend Architecture
|
| 25 |
-
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
| 26 |
-
gr.Markdown("# 🛵 Smart EV Tracker & Recommender")
|
| 27 |
-
gr.Markdown("Filter the current electric two-wheeler market based on your exact constraints.")
|
| 28 |
-
|
| 29 |
-
with gr.Row():
|
| 30 |
-
# Left Column: User Controls
|
| 31 |
-
with gr.Column(scale=1):
|
| 32 |
-
gr.Markdown("### Search Filters")
|
| 33 |
-
budget_slider = gr.Slider(minimum=50000, maximum=160000, step=5000, value=90000, label="Maximum Budget (₹)")
|
| 34 |
-
range_slider = gr.Slider(minimum=50, maximum=150, step=5, value=75, label="Minimum Range Required (km)")
|
| 35 |
-
search_btn = gr.Button("Find My EV", variant="primary")
|
| 36 |
-
|
| 37 |
-
# Right Column: Data Output
|
| 38 |
-
with gr.Column(scale=2):
|
| 39 |
-
gr.Markdown("### Recommended Models")
|
| 40 |
-
output_table = gr.Dataframe(headers=["Model", "Price (INR)", "Real Range (km)", "Top Speed (kmph)", "Charging Time (Hrs)"])
|
| 41 |
-
|
| 42 |
-
# Wire the button to the logic function
|
| 43 |
-
search_btn.click(fn=recommend_ev, inputs=[budget_slider, range_slider], outputs=output_table)
|
| 44 |
-
|
| 45 |
-
# Launch the app
|
| 46 |
-
if __name__ == "__main__":
|
| 47 |
-
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|