Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8.16 Week 10 (Halloween) Lab: Practice with lists and pandas Learning Objectives: Working with lists, understanding how tools are made How did pandas get built?

image text in transcribed
image text in transcribed
8.16 Week 10 (Halloween) Lab: Practice with lists and pandas Learning Objectives: Working with lists, understanding how tools are made How did pandas get built? What do we do if we need some functionality that is not in it? In this lab, we'll get a taste of the answers Directions Write a Python function list_col(df, col). Its first input is a pandas dataframe. Its second input is a string col that is the name (ie. label) of one of the columns of the dataframe. Your function should return a Python list that contains every unique entry in the column named col in sorted order. (As always, a docstring and meaningful variable names are required) For example, using the justide-centered database and calling its dataframe scdb as we did in examples list_col(scdb, 'chief') should return the list: ['BurgerRehnquist', 'Roberts', 'Vinson, "Warren' You may not use any pandas module methods or dataframe or series methods (other than indexing the dataframe by a col, which technically would be considered a dataframe method) No error checking is required, you may assume that there is an column with name col and that its entries are all of types that can be sorted together Also, your function does not have to work well on columns with missing or NaN values. (There are pandas isnul1() and notnull() series methods that we could use to weed out the missing values, but our goal is to make this a lab that can be done quickly so ook/UICCS111Fall201 O Type here to search TOE aCEr F12% Prt Sc Pause te Esc 8.16 Week 10 (Halloween) Lab: Practice with lists and pandas Learning Objectives: Working with lists, understanding how tools are made How did pandas get built? What do we do if we need some functionality that is not in it? In this lab, we'll get a taste of the answers Directions Write a Python function list_col(df, col). Its first input is a pandas dataframe. Its second input is a string col that is the name (ie. label) of one of the columns of the dataframe. Your function should return a Python list that contains every unique entry in the column named col in sorted order. (As always, a docstring and meaningful variable names are required) For example, using the justide-centered database and calling its dataframe scdb as we did in examples list_col(scdb, 'chief') should return the list: ['BurgerRehnquist', 'Roberts', 'Vinson, "Warren' You may not use any pandas module methods or dataframe or series methods (other than indexing the dataframe by a col, which technically would be considered a dataframe method) No error checking is required, you may assume that there is an column with name col and that its entries are all of types that can be sorted together Also, your function does not have to work well on columns with missing or NaN values. (There are pandas isnul1() and notnull() series methods that we could use to weed out the missing values, but our goal is to make this a lab that can be done quickly so ook/UICCS111Fall201 O Type here to search TOE aCEr F12% Prt Sc Pause te Esc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions