Create a single Jupyter/IPython notebook (see the Artefacts section below for all the requirements), where you...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a single Jupyter/IPython notebook (see the Artefacts section below for all the requirements), where you perform what follows. 1. Establish a connection with a new SQLite database on your disk. 2. Export all the CSV files to the said database. 3. For each of the SQL queries below (each query in a separate section), write the code that yields equivalent results using pandas only and explain - in your own words - what it does. task1_sql = pd.read_sql_query(""* ...an SQL statement... ", conn) task1_my = ( ) ...your solution using pandas... - without SQL pd.testing.assert_frame_equal(task1_sql, task1_my) # we expect no error here Important. Sometimes, the results generated by pandas will be the same up to the reordering of rows. In such a case, before calling assert_frame_equal, we should sort_values on both data frames to sort them with respect to 1 or 2 chosen columns. 1. SELECT DISTINCT engine FROM planes 2. SELECT DISTINCT type, engine FROM planes 3. SELECT COUNT(*), engine FROM planes GROUP BY engine 4. SELECT COUNT(*), engine, type FROM planes GROUP BY engine, type 5. SELECT MIN(year), AVG(year), MAX(year), engine, manufacturer FROM planes GROUP BY engine, manufacturer 6. SELECT * FROM planes WHERE speed IS NOT NULL 7. SELECT tailnum FROM planes WHERE seats BETWEEN 150 AND 210 AND year >= 2011 8. SELECT tailnum, manufacturer, seats FROM planes WHERE manufacturer IN ("BOEING", "AIRBUS", "EMBRAER") AND seats>390 9. SELECT DISTINCT year, seats FROM planes WHERE year >= 2012 ORDER BY year ASC, seats DESC 10. SELECT DISTINCT year, seats FROM planes WHERE year >= 2012 ORDER BY seats DESC, year ASC 11. SELECT manufacturer, COUNT(*) FROM planes WHERE seats > 200 GROUP BY manufacturer 12. SELECT manufacturer, COUNT(*) FROM planes GROUP BY manufacturer HAVING COUNT(*) > 10 13. SELECT manufacturer, COUNT(*) FROM planes WHERE seats > 200 GROUP BY manufacturer HAVING COUNT(*) > 10 14. SELECT manufacturer, COUNT(*) AS howmany FROM planes GROUP BY manufacturer ORDER BY howmany DESC LIMIT 10 15. SELECT flights.*, planes. year AS plane_year, planes. speed AS plane_speed, planes.seats AS plane_seats FROM flights LEFT JOIN planes ON flights. tailnum-planes.tailnum 16. SELECT planes.*, airlines.* FROM (SELECT DISTINCT carrier, tailnum FROM flights) AS cartail INNER JOIN planes ON cartail. tailnum=planes.tailnum INNER JOIN airlines ON cartail.carrier-airlines.carrier 17. An additional SQL query to implement: SELECT flights2.*, atemp, ahumid 3 FROM ( SELECT * FROM flights WHERE origin='EWR' ) AS flights2 LEFT JOIN ( SELECT year, month, day, AVG(temp) AS atemp, AVG(humid) AS ahumid FROM weather WHERE origin='EWR' GROUP BY year, month, day ) AS weather2 ON flights2.year weather2.year AND flights2.month=weather2.month AND flights2.day-weather2.day Create a single Jupyter/IPython notebook (see the Artefacts section below for all the requirements), where you perform what follows. 1. Establish a connection with a new SQLite database on your disk. 2. Export all the CSV files to the said database. 3. For each of the SQL queries below (each query in a separate section), write the code that yields equivalent results using pandas only and explain - in your own words - what it does. task1_sql = pd.read_sql_query(""* ...an SQL statement... ", conn) task1_my = ( ) ...your solution using pandas... - without SQL pd.testing.assert_frame_equal(task1_sql, task1_my) # we expect no error here Important. Sometimes, the results generated by pandas will be the same up to the reordering of rows. In such a case, before calling assert_frame_equal, we should sort_values on both data frames to sort them with respect to 1 or 2 chosen columns. 1. SELECT DISTINCT engine FROM planes 2. SELECT DISTINCT type, engine FROM planes 3. SELECT COUNT(*), engine FROM planes GROUP BY engine 4. SELECT COUNT(*), engine, type FROM planes GROUP BY engine, type 5. SELECT MIN(year), AVG(year), MAX(year), engine, manufacturer FROM planes GROUP BY engine, manufacturer 6. SELECT * FROM planes WHERE speed IS NOT NULL 7. SELECT tailnum FROM planes WHERE seats BETWEEN 150 AND 210 AND year >= 2011 8. SELECT tailnum, manufacturer, seats FROM planes WHERE manufacturer IN ("BOEING", "AIRBUS", "EMBRAER") AND seats>390 9. SELECT DISTINCT year, seats FROM planes WHERE year >= 2012 ORDER BY year ASC, seats DESC 10. SELECT DISTINCT year, seats FROM planes WHERE year >= 2012 ORDER BY seats DESC, year ASC 11. SELECT manufacturer, COUNT(*) FROM planes WHERE seats > 200 GROUP BY manufacturer 12. SELECT manufacturer, COUNT(*) FROM planes GROUP BY manufacturer HAVING COUNT(*) > 10 13. SELECT manufacturer, COUNT(*) FROM planes WHERE seats > 200 GROUP BY manufacturer HAVING COUNT(*) > 10 14. SELECT manufacturer, COUNT(*) AS howmany FROM planes GROUP BY manufacturer ORDER BY howmany DESC LIMIT 10 15. SELECT flights.*, planes. year AS plane_year, planes. speed AS plane_speed, planes.seats AS plane_seats FROM flights LEFT JOIN planes ON flights. tailnum-planes.tailnum 16. SELECT planes.*, airlines.* FROM (SELECT DISTINCT carrier, tailnum FROM flights) AS cartail INNER JOIN planes ON cartail. tailnum=planes.tailnum INNER JOIN airlines ON cartail.carrier-airlines.carrier 17. An additional SQL query to implement: SELECT flights2.*, atemp, ahumid 3 FROM ( SELECT * FROM flights WHERE origin='EWR' ) AS flights2 LEFT JOIN ( SELECT year, month, day, AVG(temp) AS atemp, AVG(humid) AS ahumid FROM weather WHERE origin='EWR' GROUP BY year, month, day ) AS weather2 ON flights2.year weather2.year AND flights2.month=weather2.month AND flights2.day-weather2.day
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these operating system questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
The new line character is utilized solely as the last person in each message. On association with the server, a client can possibly (I) question the situation with a client by sending the client's...
-
A- Farah Corporation has provided the following production and total cost data for two levels of monthly production volume. The company produces a single product which it sells at $132.7 per unit...
-
How does the balance sheet approach measure deferred taxes?
-
Current assets and current liabilities for Konex Properties Company follow: a. Determine the working capital and current ratio for 20Y9 and 20Y8. b. Is the change in the current ratio from 20Y8 to...
-
Abbott Industries is a well-known supplier of pharmaceuticals worldwide. Founded by Dr. Wallace Abbott, the company was incorporated in 1900 after he had been developing and making pharmaceuticals...
-
Steve Jackson (age 51) is a single taxpayer living at 3215 Pacific Dr., Del Mar, CA 92014. His Social Security number is 465-88-9415. In 2014, Steves earnings and income tax withholding as the...
-
A violet ray of light leaves a medium with refractive index of 6.46 at an angle of 0.07 radians to the normal and enters a second medium with refractive index of 22.04. At what angle to the normal...
-
You have been hired as an analyst for Ithmar Bank and your team is working on an independent assessment of Ahmed Foods WLL. Ahmed Foods WLL is a firm that specializes in the production of freshly...
-
How can mutual rescission take place?
-
In most situations, when a breach of contract occurs, the injured party has a duty to do what?
-
H&J Ditching & Excavating, Inc., was hired by JRSF, LLC, to perform excavating and grading work on a residential construction project in Tennessee. Cornerstone Community Bank financed the project...
-
Orlando contracts with Jane to mow Janes lawn. Orlando delegates performance of the duty to Sally with Janes assent. Who owes Jane a duty to cut her grass? a. Orlando, but not Sally. b. Sally, but...
-
Consequential damages are awarded for foreseeable losses caused by special circumstances beyond the contract. (True/False)
-
Determine the equivalent stiffness of the beam of Fig. 1-41 at the location where the machine is placed. Ms. 8. 85 x 107 N/m -60 cm- 35 cm- E=210 X 10% 1=6.52 10 m
-
What are the six activities involved in the physical supply/distribution system?
-
Clarita is a single taxpayer with two dependent children, ages 10 and 12. Clarita pays $3,000 in qualified child care expenses during the year. If her adjusted gross income (all from wages) for the...
-
Dr. Ivan I. Incisor and his wife Irene are married and file a joint return for 2012. Ivan's Social Security number is 477-34-4321 and he is 48 years old. Irene I. Incisor's Social Security number is...
-
How are qualified dividends taxed in 2012? Please give the two rates of tax which apply to qualified dividends, and specify when each of these rates applies._________________________...
-
When an organization decides to replace a legacy system, it usually chooses a contemporary database system over a relational file-based system. But each type of system has its own advantages and...
-
Complete the following sentences: system is also called a distributed data and application client/server system or
-
The textbook states that "data is a resource that must be controlled and managed." Explain this statement, and indicate whether you agree of not, and why.
Study smarter with the SolutionInn App