Saturday, August 8, 2015

Airline Route Histogram

Read the airplane and the routes ".dat" file  it into the python

After reading the files see what are the variables in the airport data and the routes data .
It consists of the Airport Id ,latitudes ,longitudes,place etc..
Let's match the latitudes and longitudes to the airport id and print the latitudes with it's corresponding  airport ID

so in order to match use the following code



 After getting the latitudes and longitudes for the corresponding Airports,we will make use of the latitudes and longitudes to calculate the distance from source and destination

 till now we matched the latitudes and longitudes and we calculated the distance based on the latitudes and longitudes
Now we will draw a histogram based on the frequency of the flights

Creating basic charts in python

In this blog we will see how to draw a charts with the help of Pyhton

Let's start with the basic program

In the above graph we have asked python to draw a plot for the values of 3,2,5,0,1,3,5,6,8,4,10
then the above plot will be obtained .


In the previous blog we discussed about the counting of votes in this we are drawing a histogram using the radish.txt file based on the number of votes each category got.
As we know champion got the maximum number of votes we can see in the graph champion has the highest peak when compared to all others

Counting the Votes Using Python

In this blog post we will see how to read a text file and perform some analysis like counting the votes.
Find the attached text  to perform the analysis  and save it as a text file.
http://opentechschool.github.io/python-data-intro/files/radishsurvey.txt 

Now after saving the file as .txt file we have to load the file into the python environment
so in order to load the file go to the python directories in your system and then paste the text file there .

 The primary objectives are

  • What's the most popular radish variety?
  • What are the least popular?
  • Did anyone vote twice?
Here the data consists of two parts one is the name and the other is to which they voted
 Here we will used functions split() and strip() -- as our raw data is clumsy we will split the data line wise and who are the person's voted for Icicle and the count for Icicle

















Now I would like to print the names of customers who only voted for a particular radish variety and lets make it little arranged. Lets take it as White Icicle.
The now I want to see how many voted for the White Icicle so we used a loop condition by using loop condition we can count how many voted
so the total members voted are 59 (highlighted in red)

Now I have to answer my objectives

who is the most and least popular
and who voted more than once ????

but here the main problem is capital letter for example
Red King
red king

Both the words are similar to us but they are different for python so in order to remove it we will use
vote = vote.strip().capitalize()
  which will remove the capital letters and make both the words 
as same to python
The other problem is double spaces in order to remove the double spaces we will use
vote = vote.replace("  ", " ")
  which will help us to remove the double spaces and keep single space
 instead of double 



So from the above we got to know that the loser is red king and plum purple with 56 votes and there are 2 people who voted twice phobe barwell and procopio zito are the two who voted twice
The other question left out is who got the maximum  number of votes
So lets go and print the WINNER.


  so the winner is champion with 76 votes