<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Analysis Workflow
This lecture takes some of the ideas we developed last week, and organizes them into a workflow. We'll do this by example, analyzing the pronto data. Topics will include
Step1:  Two challenges
1. The file is big. We don't want to download it if it's already present.
1. We're going to repeatedly download files. We don't want to just copy and paste the same code.
Encapsulating Repeated Code In Functions
A function is code that can be invoked by many callers. A function may have arguments that are specified by the caller, and returns values created by the function.
Step2:  Colin will provide more details about function, such as variable scope, and multiple return values.
<ASSISTANT_TASK:>
Python Code:
# Packages
from urllib import request
import os
import pandas as pd
# Constants used in analysis
TRIP_DATA = "https://data.seattle.gov/api/views/tw7j-dfaw/rows.csv?accessType=DOWNLOAD"
TRIP_FILE = "pronto_trips.csv"
WEATHER_DATA = "http://uwseds.github.io/data/pronto_weather.csv"
WEATHER_FILE = "pronto_weather.csv"
# Get the URL data
#request.urlretrieve(TRIP_DATA, TRIP_FILE)
!ls -lh
Explanation: Analysis Workflow
This lecture takes some of the ideas we developed last week, and organizes them into a workflow. We'll do this by example, analyzing the pronto data. Topics will include:
Retrieving data
Encapsulating repeated code into functions
Creating python modules
Organizing the analysis directory with multiple directories
These topics provide a rough outline for an analysis workflow.
Retrieving Data
End of explanation
# Example function
def xyz(input):     # The function's name is "func". It has one argument "input".
    return int(input) + 1 # The function returns one value, input + 1
print (xyz("3"))
#a = xyz(3)
#print (xyz(a))
def addTwo(input1, input2):
    return input1 + input2
#
addTwo(1, 2)
Explanation: Two challenges
1. The file is big. We don't want to download it if it's already present.
1. We're going to repeatedly download files. We don't want to just copy and paste the same code.
Encapsulating Repeated Code In Functions
A function is code that can be invoked by many callers. A function may have arguments that are specified by the caller, and returns values created by the function.
End of explanation
# Function to download from a URL
def download(url, filename):
    print("Downloading", filename)
    #request.urlretrieve(url, filename)
download(TRIP_DATA, TRIP_FILE)
# Enhancing function to detect file already present
import os.path
def download(url, filename):
    if os.path.isfile(filename):
        print("Already present %s." % filename)
    else:
        print("Downloading %s" % filename)
        #request.urlretrieve(url, filename)
        
download(TRIP_DATA, "none.csv")
import download
download.download_file(TRIP_DATA, "none.csv")
Explanation: Colin will provide more details about function, such as variable scope, and multiple return values.
End of explanation
<END_TASK>