Week_3

docx

School

McGill University *

*We aren’t endorsed by this school

Course

660

Subject

English

Date

Jan 9, 2024

Type

docx

Pages

3

Uploaded by AgentEnergy7516

Report
INSY660 Coding Foundations for Analytics 1. Function 1) Write a function that takes the temperature in Celsius and returns it in Fahrenheit F = 9 5 C + 32 2) Write a function that takes the weight and height and returns BMI BMI = Weight ( kg ) Height ( m ) 2 2. Create DataFrame that includes 5 people’s height and weight a) Generate list height_list=[] using random module. height(cm)=random.randint(150,190) b) Generate list weight_list=[] using random module. weight (kg)= random.randint(40, 120) c) Generate dataframe which includes height and weight using the list generated above. Use movies_data.csv 3. Import and Select Data a) [Code Only] Import movies_data.csv and create dataframe movies_data . b) Check the data shape c) Check the number of columns d) View the 10 rows of the movies_data e) [Code Only] Create new dataframe movies_short which contains 2 columns (budget and revenue) f) Select observations where budget greater than or equal to 5,000,000 from movies_short dataframe and report the observations (number of rows) 4. Pandas built-in function (Statistical Operation) - Use the dataframe movies_data a) Find the minimum value of each column b) Find the variance in the budget c) Find the median of the popularity 5. Sort a) Create new data frame movies_rank which contains 2 columns (title, popularity)
b) Sort by the popularity in descending order c) [Discussion] Generate rank column based on the popularity of the movie. Share your code! (There are various ways to generate rank column) 6. Plot (Use the dataframe movies_data) Draw a scatter plot in which describe the relationship between budget and the popularity as follows. Download the code (6. Titanic_Data.py) and the data(titanic.csv) from the lecture- session6 tab. => Run the code yourself and prepare for the next practice 7. [Categorical Data] a) Conduct dummy coding for the categorical variable “Embarked” based on what we’ve learned. b) Join the dummy_embarked DataFrmae to the DataFrame ‘data’ 8. [Seaborn – Graph] a) Generate a categorical bar graph using x-axis as Embarked and y-axis as Survived b) Generate a categorical bar graph using x-axis as Sex , y-axis as Survived, hue as Embarked. c) Interpret the graph created from above a) b) 9. [Group By]
a) Count the number of number of passengers(PassengerID) in first, second, and third class (Pclass) b) Find the average of the Age, Fare, Parch, PassengerID, SibSp, and Survived grouping by Sex and Pclass as follows.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help