Altaf final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

To specify unlimited number of parameters in a function, use _____

( *lots_of_parameters )

Name and ID are columns to be removed from a data frame, df1. Which of the following is the proper way to do it?

.drop( columns = ​['ID', 'Name'] )

You can supply multiple column names (col1, col2) to the drop function using

.drop( columns = ​['col1', 'col2'] )

Range (0, 5, 2) will give the range of numbers ___.

0, 2, 4

Range (4) will give the range of numbers:

0,1,2,3

Assume the following is the information of a function: ABC ( number1, [number2], [number3], [number4] ) How many arguments must be given to this function at minimum?

1

How many NA values are there in the Team Size column?

1

Will the following line of code work to change the name at index 13? df[13, 'Name'] = "Preeti"

No, this won't work because of another error

df.drop(columns= 'Name' , inplace = True)What does the drop function return?

Nothing - there is no return value

which of the following is false?

a) function can have two return values b) A function can be recognized using parentheses c) A function can return a list of values a

Write one line of code for a data frame, df that changes the value for the Name column at row 5 to 'Mike'.

df.loc​[5,'Name']='Mike'

To see the full data in row indexes 18 to 25 of a data frame, df, you can use ____.

df[18:25]

To find unique records, use ___

df​[column].unique()

Assume, you have the following data about one Amazon product: Amazon ID Number, Product Name, Product Rating, Number of ReviewsWhat data structure is this data best suited

dictionary

How would we delete all the rows with invalid cell data?

dropna

Which of the following can be used to delete a row with an NA value?

dropna()

To link multiple if conditions, use an __

elif

The function dropna() will drop ___

every row where any column value has an na value.

Which of the following is the ideal candidate for using dictionaries?

Data about one student Series of logically related values that can be described with a name or a label

print( data​['100'])The line of code above will print:

Data with index 100

A Query function will ALWAYS return subset of the data from the data frame you are working with.

False

A function with 3 arguments must return three values.

False

Back quotes are REQUIRED for column names within a query

False

Query function modifies the data frame and converts it to contain a subset of the data

False

Variables have data types in Python

False

person = {"name": "Fred", "id": "23423" }for each_item in person: print( person​[each_item] )What values would get printed out?

Fred 23423

Which is the correct way to specify keyword arguments?

method(arg1= 1, arg2 = 2)

Arguments MUST be provided in the order listed in a method definition

mostly true...but you can use kwargs to provide keyword arguments

movie = "Lord of the Rings"How would we extract "Lord" from the string?

movie​[:4] movie​[0:4]

the data type of 'is_empty' variable is

na-doesnt have a type

Which of the following properly sets up a dictionary?

name = { 'name': 'Adam', 'id': 2300 }

Which of the following would generate an error?

numbers = ​[1, 2, 3]numbers.append(4)

Using the following code, how will you print only the name?data = { 'name': 'Adam', 'id': 2300 }

print ( data​['name'])

state = "Colorado" Which of the following will return the substring "Co" in Python?

state[:2]

def function_name ( *lots_of_values ):lots_of_values is a _____

tuple parameter

How would we find out if an item is contained in a list?

use an "if" with an "in"

A CSV file contains ___

values separated by commas

Which of the following are true about return values?

A function can return only one value A function can return only one value, which can in turn contain multiple values

df.loc[10, 'Name'] = 'John' df.loc[10, 'ID'] = 200 df = df['Name'].replace('John', 'Mike') print ( df.loc[10, 'ID' ] ) What is the output?

N/A - Error

title = "Netflix and Chill"print ( title​​[0:3] )

Net

How can you get index numbers for all the rows of a data frame?

df.index

How do you EDIT cell at row 26 and column 'ABC'?

df.loc ​[26, 'ABC'] = value

How do you EDIT cell at column 'PQR' and row 27?

df.loc ​[27, 'PQR'] = value

To see row numbers 10 to 15 in data frame, df, you would use: _____.

df.loc​[10: 15]

A DataFrame ALWAYS has rows and columns

True - it's two dimensional

To convert a string to all upper case, use ___.

UPPER()

state = "Pennsylvania" Which of the following will return the substring "Penn" in Python?

state[0:4]

A Pandas series is most similar to ____

a column of data

A query function selects ____ from a data frame.

a subset of rows

A Pandas DataFrame is most similar to ____

a table of data

A pandas data frame is most resembles

a table of rows and columns

What will be the output of the following lines of code in Python?ssn = "982-23-2324" print(ssn.replace("2", "3"))

983-33-3334

Assume the following is the information of a function: ABC ( number1, number2, [number3], [number4] ) How many arguments must be given to this function at minimum?

2

numbers = ​[3, 2, 1]for i in range (0, len(numbers) ): print( numbers ​[i] )What would get printed out?

3 2 1

list_of_numbers = [ 34, 56, 67, 53, 24] print( list_of_numbers[ 2: ] ) Which numbers would be selected?

67, 53, 24

number_list = [5, 10, 15, 20] print(number_list[0] + 2) What would be the output of the statements above?

7

df.loc​[5, 'Name'] = 'Mike'df​['Name'].replace('Mike', 'Sam')print ( df.loc​[5, 'Name'] )What is the output?

Mike

For a student dataframe that contains student info, the names column has student names.student_df​['name'].str.contains("jr.")What will this code return or result in?

One series of boolean values indicating which rows have "jr." in the name

number = 5if number > 5 :print ("a")else:print("b")What is the output of the code above?

Something else / error

A CSV consists of only one value, 50. When imported as a Data Frame, it would have rows and columns. Incorrect answer:

True

Column names with spaces should be enclosed in ____ within Pandas queries.

back quotes ``

A TUPLE _____, whereas a LIST ____.

cannot be modified , can be modified

Create a new method using the keyword ___

def

Which of the following keywords creates a new function?

def

How would we drop a row that has a value "adf2234" at index row 26?

df.drop(index=26)

Which of the following results in a series of True/False values?

df.duplicated( )

name = "Smurfette" print (name[4:]) What would be the output of the above set of statements in Python?

fette

How do we change all na values to a specific value?

fillna

Which of the following can be used to replace an NA value with a zero?

fillna()

A(n) _____ name is followed by parentheses in Python.

function

A query is run on a DataFrame df. The result of the query are stored in a variable, df2.df2 will ____.

have same or fewer rows AND same columns as df.

If you want to be able to have items in a data structure ordered by index numbers and be able to remove some elements later on as well, you would choose ____.

lists

How would we look up how many null values there are in the dataframe?

info()

To look at column headers for a DataFrame, you can use ___

info() head() tail()

Which of the following would cause an original DataFrame to be modified?

inplace = True

If you want to make changes to the original dataframe, use ___.

inplace=true

When a function returns a value, it ______.

is given back to the caller function invisibly

Be default, if to_numeric() function encounters a string, it ____

is unable to do the conversion and the function crashes with an error

a _ name is not followed by parentheses in a function

property, variable,attribute

Which of the following generates range numbers from 0 to 4 (inclusive of 4)?

range (0, 5) range(5)

To get numbers4, 2, 0use

range (4, -1, -2)

numbers = ​[1, 2, 3]for i in _________: print( numbers ​[i] )Fill in the blank so that the loop above works properly.

range( 0, len(numbers) range( len(numbers) )

To open a CSV file in Pandas, use ___

read_csv(url)

If you were given a file which had data separated by semi-colons, i.e. a ';' character, you could load it in Pandas by using ____.

read_csv(url, sep = ';')

For a tab-delimitted file, how would you specify that the values are delimited using a tab character?

sep = '\t'

df​[column].isna() will return you ____.

series of booleans

You are importing customer data from 4 sources. If you want a non-repetitive listing of only those states that your customers are in, you should import or copy customer data into ____.

sets

A Series in Pandas likely contains ____.

single column and multiple rows

How do we get the character with index 4 from the string?star = "Maverick"

star​[4]

To type for the value of "99.32" is

string

In Python to extract leading/trailing spaces, use ___.

strip

What does the following code result in?name = Peterprint ( name​[2:] )

ter

list of products = ​[ { 'product': 'Paper', 'id': '243098', 'rating': '4.5' }, { 'product': 'Pens', 'id': '7678', 'rating': '3.2' }, { 'product': 'Markers', 'id': '43263', 'rating': '3.8' } ]for each_product in list_of_products:print( each_product )What will the for loop print in the first iteration? (first time it loops)

the first dictionary literal

The purpose of keyword arguments is _____.

to allow specification of arguments out of order by using argument names


Ensembles d'études connexes

Chapter 39: Nutritional Problems

View Set

Chapter 70: Management of Patients With Oncologic or Degenerative Neurologic Disorders

View Set

The Classical Period with Greece and Rome

View Set

Micro - Analysis of Laboratory Techniques lab quiz 2

View Set