Question

In Python How do I make the following function below iterate for 20 years. (1996 to...

In Python How do I make the following function below iterate for 20 years. (1996 to 2016)

def getComplaints(year, make, model):
url0 = #url
url = url0.format(year,make,model)
s = requests.get(url).text # this is a CSV string
df = pandas.read_csv(StringIO(s)) # use pandas to parse the CSV
complaints = df.to_dict('records') # convert to list of dicts
return complaints

I want to change this function so it is able to search from the year 1996 all the way to 2016 and then return the dictionary complaints. Any idea on how to change the above function so that it does this?

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
In Python How do I make the following function below iterate for 20 years. (1996 to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Python, if you could help me with the code # Create a modified version of the search linear function defined # above to return all # occurrences of the search word in the text # An occurrence is...

    Using Python, if you could help me with the code # Create a modified version of the search linear function defined # above to return all # occurrences of the search word in the text # An occurrence is the index of a word in the text that matches your given # search string. # e.g. if "hatter" occurs at positions 0, 6, 12 then return [ 0, 6, 12] def search_linear_occurrences(xs, target): """ Find and return a list of...

  • You have just been hired as an analyst for an investment firm. Your first assignment is...

    You have just been hired as an analyst for an investment firm. Your first assignment is to analyze data for stocks in the S&P 500. The S&P 500 is a stock index that contains the 500 largest publicly traded companies. You have been given two sources of data to work with. The first is an XML file that contains the Symbol (ticker), company name, sector, and industry for every stock in the S&P 500, as of summer 2016. The second...

  • Python function: This is my code and I don't know how to add the column to...

    Python function: This is my code and I don't know how to add the column to the csv file: def write_with_averages(read,write): with open (read,'r') as f_in: header = f_in.readline() reader=csv.reader(f_in) with open (write,'w') as f_out: writer=csv.writer(f_out) New_data=[] for Name, Test1, Test2, Test3 in reader: Total=(float(Test1)+float(Test2)+float(Test3)) average=Total/3 New_data.append(average) Hint: Skip the first line of the file as it is a header line Hint: All values come in as strings, so convert to floats before mathematical comparisons and calculations. File Format Name,Test1,Test2,Test3...

  • [Python] I have the following function that removes all non-numerical characters from a string: d...

    [Python] I have the following function that removes all non-numerical characters from a string: def remove_non_numeric(s):    seq_type= type(s) return seq_type().join(filter(seq_type.isdigit, s)) And I need help implementing it into this function: def list_only_numbers( a_list ) : # Create a new empty list. # Using a loop (or a list comprehension) # 1) call remove_non_numeric with a list element # 2) if the return value is not the empty string, convert # the string to either int or float (if it contains...

  • This is a python question. Start with this program, import json from urllib import request def...

    This is a python question. Start with this program, import json from urllib import request def main(): to_continue = 'Yes' while to_continue == 'yes' or to_continue == 'Yes': currency_code = input("Enter currency code: ").upper() dollars = int(input("Enter number of dollar you want to convert: ")) # calling the exchange_rates function data = get_exchange_rates() if currency_code in data["rates"].keys(): currency = data["rates"][currency_code] # printing the the currency value by multiplying the dollars amount. print("The value is:", str(currency * dollars)) else: print("Error: the...

  • Python: I need help with the following quit function ! The quit menu option should not...

    Python: I need help with the following quit function ! The quit menu option should not be case sensitive - 'q' or 'Q' should quit the program menu.add_option('Q', 'Quit', quit_program) NB: Remaining code ! """ Program to create and manage a list of books that the user wishes to read, and books that the user has read. """ from bookstore import Book, BookStore from menu import Menu import ui store = BookStore() def main(): menu = create_menu() while True: choice...

  • Use of search structures! how can i make this program in python? Learning Objectives: You should...

    Use of search structures! how can i make this program in python? Learning Objectives: You should consider and program an example of using search structures where you will evaluate search trees against hash tables. Given the three text files under containing the following: - A list of students (classes Student in the distributed code) - A list of marks obtained by the students (classes Exam results in the distributed code) - A list of topics (classes Subject in the distributed...

  • Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can...

    Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can be solved in one post so I posted the other on another question so please check them out as well :) Here is the questions in this assignment: Note: Two helper functions Some of the testing codes for the functions in this assignment makes use of the print_dict in_key_order (a dict) function which prints dictionary keyvalue pairs...

  • I have a python project that requires me to make a password saver. The major part...

    I have a python project that requires me to make a password saver. The major part of the code is already giving. I am having trouble executing option 2 and 3. Some guidance will be appreciated. Below is the code giving to me. import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store the passwords to passwordFileName = "samplePasswordFile" #The encryption key for the caesar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT