USING PYTHON: Notes at the end Two large files are needed to answer these questions, however they
Fantastic news! We've Found the answer you've been seeking!
Question:
USING PYTHON: Notes at the end
Two large files are needed to answer these questions, however they are too large and cannot be uploaded, if possible, please help understand code by answering to the best of your ability.
Transcribed Image Text:
Find Texas population. Hint: total population of Texas in 2010 census was 25.1 Million. In [5]: from census 2010 import allData import pandas as pd In [44]: pops pops = = pd. '?' (allData['TX']) # convert it to a data frame In [47]: TXPopulation TXPopulation TXPopulation = pops.'?1'('?2) [0] # 21: function that adds up :-) ?2: the addition function works # recall that the addition function works column wise Out [47]: 25145561 Question 1.b (15 points): US population Find total population of US. Hint: total population of Texas in 2010 census was 308.7 Million. In [15]: total_pop = 0 In [ ]: total pop Out [15]: 308745538 for var in allData.'?'(): # allData is a dictionary. We Loop through its keys. pops = pd. '?' (allData["?"]) # convert it to a data frame # the sum works row wise. total pop pops.sum("?")[0] Question 1.c (10 points): The most populated TX county Find the most populated county in Texas In [48]: TXCountMaxPop TXCountMaxPop = pops."?1"("?2") [0] # ?1: function to find the largest value #22: function 21 works row wise TXCountMaxPop Out [48]: 4092459 In [] In [51]: county = "?" # create an empty list for var in list (pops): if pops.loc ['pop',"?"] == TXCountMaxPop: county. '?'(var) # add var to the list county print(county) ['Harris'] Question 1.d (15 points): the most populated county in each state Find the most populated county in each state. HighpopCounty = '?' # create an empty dictionary for state in allData."?"(): # we what to Loop through keys of the dictionary pops = pd. '?1' (allData['?2']) # ?1: convert to data frame, ?2: this value comes from the for Loc CountMaxPop pops.max (axis=1)[0] = for county in list(pops): if pops.loc ['pop', '?'] == CountMaxPop: #?: this value comes from the for Loop :-) HighpopCounty[state] = {} HighpopCounty[state] [county] = CountMaxPop HighpopCounty Question 2 (20 points): import alic.txt and cound the number of words and characters in it. Count the number of words in the txt file and find the most repeated one. In your program, first convert all words to lower case and then convert the first character to the upper case. Then do the analysis. We are not interested in the following words: The, A, And, To, It Banwords=['The', 'A', 'And', 'To', 'It'] |filename = 'alice.txt' text = '?' (filename) #open the file print('Please Wait, Counting the number of words..') counts = ?' # create an empty dictionary the file for line? text: # keyword in the for Loop line line.'?'() #convert to Lower Lettres. line = line. '?'() #convert the first letter to capital lettre. words = line.'?'() #spereate the words in the Line based on whitespace for word in words: word = word.rstrip(''').,'s,'5,)",)")`"''') word = word. 1strip('''(,", (","(''') if word "?" in Banwords: # the missing keyword Let the Loop continue if the word is not in if word in counts: counts [word] = counts [word]+1 counts [word] = 1 MaxRep = 0 Maxword = 4 else: for k,v in counts. '?'(): # we need both keys and values of the dictionary in the Loop :-) if v > MaxRep: MaxRep = v Maxword = k print (Maxword, is the most repeted word with ',MaxRep, 'times') Find Texas population. Hint: total population of Texas in 2010 census was 25.1 Million. In [5]: from census 2010 import allData import pandas as pd In [44]: pops pops = = pd. '?' (allData['TX']) # convert it to a data frame In [47]: TXPopulation TXPopulation TXPopulation = pops.'?1'('?2) [0] # 21: function that adds up :-) ?2: the addition function works # recall that the addition function works column wise Out [47]: 25145561 Question 1.b (15 points): US population Find total population of US. Hint: total population of Texas in 2010 census was 308.7 Million. In [15]: total_pop = 0 In [ ]: total pop Out [15]: 308745538 for var in allData.'?'(): # allData is a dictionary. We Loop through its keys. pops = pd. '?' (allData["?"]) # convert it to a data frame # the sum works row wise. total pop pops.sum("?")[0] Question 1.c (10 points): The most populated TX county Find the most populated county in Texas In [48]: TXCountMaxPop TXCountMaxPop = pops."?1"("?2") [0] # ?1: function to find the largest value #22: function 21 works row wise TXCountMaxPop Out [48]: 4092459 In [] In [51]: county = "?" # create an empty list for var in list (pops): if pops.loc ['pop',"?"] == TXCountMaxPop: county. '?'(var) # add var to the list county print(county) ['Harris'] Question 1.d (15 points): the most populated county in each state Find the most populated county in each state. HighpopCounty = '?' # create an empty dictionary for state in allData."?"(): # we what to Loop through keys of the dictionary pops = pd. '?1' (allData['?2']) # ?1: convert to data frame, ?2: this value comes from the for Loc CountMaxPop pops.max (axis=1)[0] = for county in list(pops): if pops.loc ['pop', '?'] == CountMaxPop: #?: this value comes from the for Loop :-) HighpopCounty[state] = {} HighpopCounty[state] [county] = CountMaxPop HighpopCounty Question 2 (20 points): import alic.txt and cound the number of words and characters in it. Count the number of words in the txt file and find the most repeated one. In your program, first convert all words to lower case and then convert the first character to the upper case. Then do the analysis. We are not interested in the following words: The, A, And, To, It Banwords=['The', 'A', 'And', 'To', 'It'] |filename = 'alice.txt' text = '?' (filename) #open the file print('Please Wait, Counting the number of words..') counts = ?' # create an empty dictionary the file for line? text: # keyword in the for Loop line line.'?'() #convert to Lower Lettres. line = line. '?'() #convert the first letter to capital lettre. words = line.'?'() #spereate the words in the Line based on whitespace for word in words: word = word.rstrip(''').,'s,'5,)",)")`"''') word = word. 1strip('''(,", (","(''') if word "?" in Banwords: # the missing keyword Let the Loop continue if the word is not in if word in counts: counts [word] = counts [word]+1 counts [word] = 1 MaxRep = 0 Maxword = 4 else: for k,v in counts. '?'(): # we need both keys and values of the dictionary in the Loop :-) if v > MaxRep: MaxRep = v Maxword = k print (Maxword, is the most repeted word with ',MaxRep, 'times')
Expert Answer:
Related Book For
Business Ethics A Stakeholder And Issues Management Approach
ISBN: 9781523091546
7th Edition
Authors: Joseph W. Weiss
Posted Date:
Students also viewed these programming questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
What is the output of the following application? A. 5,LONG B. 6,LONG C. 5,null D. 6,null E. The code does not compile. F. The code compiles but throws an exception at runtime. package fly; public...
-
Read about the Balanced Scorecard, compare and contrast the Balanced Scorecard to one of the IT frameworks below (COBIT, ITIL, TOGAF, and CMMI-Dev). Describe the context in which the Balanced...
-
James T. Adams was a partner at Deloitte a partner with a gambling issue. He ended up borrowing tens of thousands of dollars from a casino a casino that he was in charge of auditing. Does he face...
-
Retro Furniture Pty Ltd uses a job order costing system. The September cost data were as follows. Machine hours for September were 55 700 hours, and the business applies factory overhead to...
-
From the following list, identify the accounts that should be closed to Income Summary at the end of the fiscal year: a. Accounts Receivable b. Accumulated DepreciationEquipment c. Depreciation...
-
A rigid container contains an ideal gas 40C which is stirred by a blade. The blade produces 200kJ of work. The temperature remains constant thanks to a heat exchange with the surroundings which are...
-
Required information [The following information applies to the questions displayed below.] The following transactions apply to Jova Company for Year 1, the first year of operation: 1. Issued $27,000...
-
Define the term "Financial Engineering" and explain 3 main components of financial engineering. (8 marks) Question 2 1) Explain the factors responsible for financial innovations. (12 marks) Question...
-
Last year s contribution format income statement for Huerra Company is given below: Total Unit Sales $ 1 , 0 0 8 , 0 0 0 $ 5 0 . 4 0 Variable expenses 6 0 4 , 8 0 0 3 0 . 2 4 Contribution margin 4 0...
-
Lofty Ltd has been acquired by Holdco Ltd . At the time of acquisition on March 1 0 th 2 0 2 3 , Lofty Ltd . had non - capital business losses of $ 6 0 0 , 0 0 0 carried forward from 2 0 2 2 , and $...
-
Dickinson Company has $11,880,000 million in assets. Currently half of these assets are financed with long-term debt at 9.4 percent and half with common stock having a par value of $8. Ms. Smith,...
-
Answer the following questions in full. 1 . Explain the difference between a trade discount and a cash discount. 2 . Give a mathematical example of a trade discount, whereby the original price is $ 1...
-
Congratulations, you were just recently hired by Bailey's Boating World, Inc. as their new accounting intern this summer! Your first job is to prepare their financial statements for their year ended...
-
J Limited owns its own office property. The revaluation model has been adopted and the office property has been revalued to $3,600,000 as at 31st December 2020 from its book value of $2,000,000 prior...
-
If the amplifier indicated by the box input impedance of oo, which of the following statements are true ? has an open loop gain as well as Feedback factor (\beta = 1/ R_1\) The feedback is voltage...
-
Explain what ethical logic and actions people generally take to persuade you to do something that is ethically questionable. Refer to the ethical decision styles in the chapter.
-
Identify one myth you had/have about business ethics. Where did it originate? Why is it a myth? What led you to abandon this myth, or do you still believe in it? Explain.
-
Describe a recent crisis that involved a product. Which phase of the crisis management model do you believe is the most important for all involved stakeholders? Explain.
-
What is the relation between the square of the mean velocity and the mean of the velocity squared in the context of the Boltzmann distribution?
-
The distribution of the energy of the molecules is also of importance in the kinetics of chemical reactions. The fraction of molecules with energy in the range between \(E\) and \(E+d E\) is given...
-
The simple formula \(C_{p}=(5 / 2) R\) (molar units) is valid only for monatomic gases. A simple extension that has been suggested is \[C_{p}=\left(5+N_{\mathrm{r}} ight) \frac{1}{2} R\] where...
Study smarter with the SolutionInn App