QuestionQuestion

Transcribed TextTranscribed Text

Q1Why we need Python virtual environments? Please write no more than 3 lines. write you response here Q2Sort following list in place alphabetically using last three character In [ ]: continentsL = ['Europe', 'Africa', 'America', 'Antarctica', 'Asia', 'Australia'] # Write you code in the next line Q3(We want to compare random integer generation time in numpy and random module of python. Generate 100 random integer in the range 1 to 10 including 1 and 10. Write jupyter notebook line magic to compare execution time of random integer generation in the following cells(look for the cells having the comment write line magic). Line magic must execute the given statement 10 times in a loop and repeats 5 times. Hints: Note that numpy.random has randint function and random has random.randint function. Press shift+tab after typing above function or search their documentation to understand their parameters. use?onmagiccommandtimeitforfurtherdocumentation.seehowtouse -nand-roptions. In [ ]: import random num_sample = 100 low = 1 high = 10 In [ ]: # write line magic for random module in the next line In [ ]: import numpy as np In [ ]: # write line magic for numpy randint in the next line To start working toward final project, complete the following questions by writing markdown in the same cell in next line. Each question in worth the samecell in next line. In tools 1 course, we are concerned with data cleaning, feature engineering and exploratory analysis. Make sure your selected final project allows for lots of data cleaning, transformation and engineering opportunity. Go over project and presentation rubric in course webpage to better understand the requirement for the project. We will evaluate the answer to see if it meets the final project requirements. Q6 Describe the attributes of examples in the dataset. If you are planning to collect the data(webscrapping, web API etc.), list the time line to finish the data collection. write you response here Q7 Give example of records(sample points). Why this is a noisy data set(highlight portion of record attributes you think are noisy). write you response here Q8 What kind of feature engineering opportunity you see. We'll cover feature engineering but here are some examples to get an idea of feature engineering. Do you need to extract a number, year, or a word in column(attribute of a record). Like may be extracting Miss, Mr., Dr. is more inportant than actual name. May be year or time is embbedded in the text desciption and it is important for analysis. If a column has numerical values. Do you see a potential for using these values or a transformation of these values like square, log etc? write you response here Q1(Remove the blank lines from the customer_record.csv using grep command and regular expression. You may have to read grep documentation to look for more otpion. Run following cell to create customer_record.csv In [10]: !echo "customer,items, type, quantity" > customer_history.csv; echo "Allen, Statistical analysis, book, 2" >> customer_history.csv;echo "">> customer_history.csv; echo "Jhon, Ka sa Smart Wi-Fi Plug, electronics, 3" >>customer_history.csv; echo "Tim,Unix Shell Program ming, Book, 3" >> customer_history.csv; echo "">> customer_history.csv; echo "Allen,Pyth on for Data Analysis, Book, 1">> customer_history.csv In [11]: ! cat customer_history.csv customer,items, type, quantity Allen, Statistical analysis, book, 2 Jhon, Kasa Smart Wi-Fi Plug, electronics, 3 Tim,Unix Shell Programming, Book, 3 Allen,Python for Data Analysis, Book, 1 In [29]: # Write code in the next line Q2(Use previous grep command and a combination of commands using pipe(|), print uniq customer name in capital letters. In [30]: # write commands using ! in the next line Other useful command we didn't cover in the class is mkdir, find and wc. Look for their documentation. Sometime we forget where the file are in the filesystem. find commmand is really useful for searching files in filesystem. To learn these command we wil use them in following excercises Let's make dataset_zyx_dec_2050/train and dataset_zyx_dec_2050/validation directory and add some files in them. Run the following commands to make directories and files. In [18]: !mkdir -p dataset_zyx_dec_2050/train !mkdir -p dataset_zyx_dec_2050/validation In [20]: !for i in $(seq !for i in $(seq !for i in $(seq !for i in $(seq 5); do touch dataset_zyx_dec_2050/validation/cat$i.jpg ;done 5); do touch dataset_zyx_dec_2050/validation/cat$i.tfrecord ;done 5); do touch dataset_zyx_dec_2050/train/cat$i.jpg ;done 5); do touch dataset_zyx_dec_2050/train/dog$i.jpg ;done contents of dataset_zyx_dec_2050/validation and dataset_zyx_dec_2050/train In [22]: !ls dataset_zyx_dec_2050/train cat1.jpg cat3.jpg cat5.jpg dog2.jpg dog4.jpg cat2.jpg cat4.jpg dog1.jpg dog3.jpg dog5.jpg In [23]: !ls dataset_zyx_dec_2050/validation cat1.jpg cat2.jpg cat3.jpg cat4.jpg cat5.jpg cat1.tfrecord cat2.tfrecord cat3.tfrecord cat4.tfrecord cat5.tfrecord Q3Print all the files starting with the namecat in the subfolders of dataset_zyx_dec_2050 using find command. In [31]: #write your command in next line # Hint ./use dataset_zyx_dec_2050 and read about -name option in the find command Q4(.Count number of cat file using pipe andwc command. In [32]: #write your commands in the next line Q5(.Using answer of Q2, find the total number of unique customer In [33]: # write your code in the next line Let's say you work for an e-commerce company and you are on call. Due to some recent feature pushed to the production, a severity 1 ticket is raised. The ticket states that some to the severity 1 ticket is raised. The ticket states that some to the customers are charged multiple time this month. You task is to quickly find the affected customer and manually credit back the amount. Run the followoing cell to generate the the payment_gateway.logxx file In [24]: %%bash echo "customer:2150:credit_card:xxxx-xxxx-xxxx:charged:\$50 customer:2350:credit_card:xxxx-xxxx-xxxx:charged:\$20 Paymenet gateway: STATUS 200 customer:3456 payment failed customer:3350:credit_card:xxxx-xxxx-xxxx:charged:\$71 customer:4350:credit_card:xxxx-xxxx-xxxx:charged:\$50 customer:2350:credit_card:xxxx-xxxx-xxxx:charged:\$20 ncustomer:2150:credit_card:xxxx-xxxx-xxxx:charged:\$50 customer:3350:credit_card:xxxx-xxxx-xxxx:charged:\$71 customer:2350:credit_card:xxxx-xxxx-xxxx:charged:\$20 customer:2350:credit_card:xxxx-xxxx-xxxx:declined charged:attempt:3" > payment_gateway.lo gxx In [25]: # Here are the file content !cat payment_gateway.logxx customer:2150:credit_card:xxxx-xxxx-xxxx:charged:$50 customer:2350:credit_card:xxxx-xxxx-xxxx:charged:$20 Paymenet gateway: STATUS 200 customer:3456 payment failed customer:3350:credit_card:xxxx-xxxx-xxxx:charged:$71 customer:4350:credit_card:xxxx-xxxx-xxxx:charged:$50 customer:2350:credit_card:xxxx-xxxx-xxxx:charged:$20 ncustomer:2150:credit_card:xxxx-xxxx-xxxx:charged:$50 customer:3350:credit_card:xxxx-xxxx-xxxx:charged:$71 customer:2350:credit_card:xxxx-xxxx-xxxx:charged:$20 customer:2350:credit_card:xxxx-xxxx-xxxx:declined charged:attempt:3 Q6(Use payment_gateway.logxx file to find the number of times a customer is charged and the line corresponding to the customer record. Only print lines for customers charged more than one time. Hint: for customer 2350 line output should be 3 customer:2350:credit_card:xxxx-xxxx-xxxx:charged:$20 In [34]: # Write you commands in the next line Part Access the NASA API using "DEMO_KEY" as Pooran did in lesson 3, part 4. Extract the URL for astronomy picture of the day and view it in a browser. ---------------------------------------------------------------------- ------- Part 2 Construct an HTML file that renders in a browser. It should have a head and a body. The head should have a title. The body should have four paragraphs, two of which should have a class attribute. The paragraphs should have at least two lines. Copy that content into your editor and assign the result as a string to be passed as a parameter to an instance of Beautiful Soup. Use requests, lxml, and beautiful soup to print the following in turn: all of it the title each paragraph that has a class attribute by that attribute all the paragraphs the whole thing with get_text Assignment 5, Part 1: Construct a CSV with the first eight elements of the periodic table of elements. Include columns containing name, symbol, and atomic number. Read that into a pandas DataFrame. Inside the program add a nineth and tenth element then add a column with the atomic weights rounded to the nearest integer. Assignment 5, Part 2: Make a list of strings for nine Greek letters, ‘alpha’, for example. Make that list such that they are not in alphabetic order. Make two 9-element numpy arrays of random floating-point numbers with the estimated mean 10 and standard deviation 1.5. Make another array of nine elements ranging from zero to two times pi. Name it ‘angle’. Make another array holding the cosine of that ‘angle’ array. Construct a dictionary from all of the above. Form a DataFrame from that dictionary and print it out. Sort the DataFrame ascending on the Greek letters, drop two columns of your choice, drop one of the rows, and print that out. Assignment 5, Part 3: Write a program in Python to create and print out the first twelve Fibonacci numbers. Then iterate over the last five numbers to build another list with the ratio of each number to its predecessor. What do you observe about this latter list? Assignment 5, Part 4: Provide a function that converts temperature in Kelvin to Rankine. Make a list of five Kelvin temperatures and print out their values in Rankine. Repeat using a lambda function. Assignment 5, Part 5: Construct a Pandas dataframe with two columns of 100 random numbers drawn from a normal (Gaussian) distribution. Divide the DF into two with a 75-25 split at random. Reset the indices of each new DF. Print the first 12 lines of each. Compute the mean and standard deviation of each column of each new DF. Assignment 5, Part 6: Load the Titanic dataset (a Seaborn built-in) into a DF. Compute the survival rate for each passenger class based on sex. Use the cut method to create three bins to hold the passenger ages in catagorical form. Hint: use [0,18,25,99] and ['kid','young_adult','adult'].

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

    By purchasing this solution you'll be able to access the following files:
    Solution1.ipynb, Solution2.ipynb and Solution3.zip.

    $144.00
    for this solution

    or FREE if you
    register a new account!

    PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

    Find A Tutor

    View available Python Programming Tutors

    Get College Homework Help.

    Are you sure you don't want to upload any files?

    Fast tutor response requires as much info as possible.

    Decision:
    Upload a file
    Continue without uploading

    SUBMIT YOUR HOMEWORK
    We couldn't find that subject.
    Please select the best match from the list below.

    We'll send you an email right away. If it's not in your inbox, check your spam folder.

    • 1
    • 2
    • 3
    Live Chats