sathaye3 commited on
Commit
1640a33
ยท
verified ยท
1 Parent(s): 8864994

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +85 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import altair as alt
4
+
5
+ st.set_page_config(page_title="UFO Sightings", layout="centered")
6
+
7
+ st.title("๐Ÿ›ธ UFO Sightings Analysis")
8
+ st.markdown("Explore trends in UFO sightings across time and shape types using data from the [UFO Sightings dataset](https://github.com/UIUC-iSchool-DataViz/is445_data/raw/main/ufo-scrubbed-geocoded-time-standardized-00.csv).")
9
+
10
+ url = "https://github.com/UIUC-iSchool-DataViz/is445_data/raw/main/ufo-scrubbed-geocoded-time-standardized-00.csv"
11
+ df = pd.read_csv(url, low_memory=False)
12
+
13
+ if 'date_time' not in df.columns:
14
+ df.columns = df.columns.str.strip()
15
+ if 'datetime' in df.columns:
16
+ df.rename(columns={'datetime': 'date_time'}, inplace=True)
17
+ elif df.columns[0].lower().startswith("10/10/"):
18
+ df.columns = ['date_time', 'city', 'state', 'country', 'shape', 'duration_seconds',
19
+ 'duration_hours_min', 'comments', 'date_posted', 'latitude', 'longitude']
20
+
21
+ df['date_time'] = pd.to_datetime(df['date_time'], errors='coerce')
22
+ df['year'] = df['date_time'].dt.year
23
+
24
+ st.header("๐Ÿ”บ Plot 1: Most Common UFO Shapes")
25
+
26
+ shape_counts = df['shape'].value_counts().reset_index()
27
+ shape_counts.columns = ['shape', 'count']
28
+
29
+ bar_chart = alt.Chart(shape_counts.head(10)).mark_bar().encode(
30
+ x=alt.X('shape:N', sort='-y', title='UFO Shape'),
31
+ y=alt.Y('count:Q', title='Number of Sightings'),
32
+ tooltip=['shape', 'count']
33
+ ).properties(width=600, height=400)
34
+
35
+ st.altair_chart(bar_chart, use_container_width=True)
36
+
37
+ st.markdown("""
38
+ **What is being visualized:**
39
+ This bar chart displays the ten most frequently reported UFO shapes. It offers insight into how witnesses categorize their sightings.
40
+
41
+ **Design choices:**
42
+ - Bar chart format allows for easy comparison of categorical frequency.
43
+ - Sorted bars make the distribution immediately understandable.
44
+ - Tooltips reveal the exact number of sightings for each shape.
45
+ - Missing data in the shape column was excluded to ensure clarity.
46
+
47
+ **Data manipulation:**
48
+ Used `value_counts()` to aggregate the number of sightings for each shape. Top 10 shapes were selected for focused comparison.
49
+
50
+ **What I would change:**
51
+ I would include filters to isolate shapes over time or by country for deeper analysis.
52
+ """)
53
+
54
+ st.header("๐Ÿ“ˆ Plot 2: UFO Sightings Over Time")
55
+
56
+ sightings_by_year = df.groupby('year').size().reset_index(name='count')
57
+ sightings_by_year = sightings_by_year[sightings_by_year['year'].between(1950, 2020)]
58
+
59
+ line_chart = alt.Chart(sightings_by_year).mark_line(point=True).encode(
60
+ x=alt.X('year:O', title='Year'),
61
+ y=alt.Y('count:Q', title='Number of Sightings'),
62
+ tooltip=['year', 'count']
63
+ ).properties(width=700, height=400)
64
+
65
+ st.altair_chart(line_chart, use_container_width=True)
66
+
67
+ st.markdown("""
68
+ **What is being visualized:**
69
+ This line chart shows the number of UFO sightings reported each year, highlighting long-term trends in reporting behavior.
70
+
71
+ **Design choices:**
72
+ - A line chart illustrates the temporal flow of sightings.
73
+ - Point markers add precision for each year's count.
74
+ - Ordinal x-axis ensures chronological accuracy.
75
+ - Tooltips improve user insight with exact values.
76
+
77
+ **Data manipulation:**
78
+ Converted `date_time` to datetime, extracted the `year`, grouped by it, and filtered for realistic years (1950โ€“2020).
79
+
80
+ **What I would change:**
81
+ I would add geographic filters or layer in shapes per year to explore how different UFO types have evolved over time.
82
+ """)
83
+
84
+ st.markdown("---")
85
+ st.markdown("๐Ÿ“„ **Data Source**: [UFO Sightings Dataset (CSV)](https://github.com/UIUC-iSchool-DataViz/is445_data/raw/main/ufo-scrubbed-geocoded-time-standardized-00.csv)")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ altair