Question: UFO Python Download the ufo _ sightings.csv file that is located on this web page to the same directory where your Program 6 python file
UFO Python Download the ufosightings.csv file that is located on this web page to the same directory where your Program python file is located.
Use pandas andor matplotlib to produce two different visualizations that help the user gain insight into the information contained in the csv file. points pandas andor matplotlib are used to produce two insightful visualizations. All or nothing.
points Each visualization is a different type. For example, one visualization could be a bar chart and the other could be a pie chart. All or nothing.
points The visualizations use the underlying data to show different things. All or nothing.
points All aspects of each visualization are clearly labeled. points for each type of improvement up to points.
points The first visualization yields an interesting insight that is explained in a comment at the top of your program. For example, if the program visualized the Montana population by decade, the population is flat to decreasing from to This is interesting because populations normally increase and is explained by drought and depression.
points The second visualization yields an interesting insight that is explained in a comment at the top of your program, similar to the requirement for the first visualization.
points The Python solution is properly commented, easy to understand and does not contain unnecessary code. points for each type of improvement up to points.
code:
# Importing required libraries
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# First Visualization: Number of UFO Sightings by Year
# This visualization helps us understand the trend of UFO sightings over time
# Interesting insight: The number of UFO sightings seems to increase significantly after the s
# lowest recorded year
def siteyeardatafile:
fig pltfigure
ax fig.addsubplot
axhistdatafileDatesDocumented.Year' binsrange align'right'
axsettitleNumber of UFO Sightings by Year'
axsetxlabelYear
axsetylabelNumber of Sightings'
pltxticksrotation # Get or set the current tick locations and labels of the xaxis.
pltxlimleftmindatafileDatesDocumented.Year'min
pltxlimrightmaxdatafileDatesDocumented.Year'max
pltgrid
pltgcasetfacecolor#fff
#pltsavefigufosightingsbyyear.png # saves a fancy image
pltshow
printThe first visualization reveals an increase in UFO sightings after
# Second Visualization: Distribution of UFO Shapes
# This visualization helps us understand the most common shapes reported for UFOs
# Interesting insight: Circular shapes are the most commonly reported UFO shapes
def distshapedatafile:
fig pltfigure
ax fig.addsubplot
axpiedatafileDataShape'valuecountssortindex labelsdatafileDataShape'valuecountsindex, autopctf
axaxisequal
axsettitleDistribution of UFO Shapes'
pltshow
printThe second visualization shows that circular type shapes are the most common UFO shapes reported."
def main:
# Loading the CSV file into a DataFrame
ufodata pdreadcsvufosightings.csv # reads file from panda, pd
siteyearufodata
distshapeufodata
main
# printufodata.columns
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
