Python - Introduction to Pandas and DataFrames

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What happens when we call the stack () function on a Pandas DataFrame

It will create a new DataFrame such that a single row in the original DataFrame is stacked into multiple rows in the new DataFrame depending on the number of columns for each row in the original DataFrame

Match the following statements related to the iloc indexer in Pandas with the correct boolean values.

When we pass 2:6 as input argument to the iloc function, we get all details of the records located in the second index all the way up to the 5th index of the DataFrame (false) The iloc indexer is similar to the loc indexer and can be used to access records located at a particular index in a Pandas DataFrame (true) The column headers can be passed as input arguments in the form of a string to the iloc function without any errors (false)

Let's say you have a pandas DataFrame called "frame" and you want to export this DataFrame along with its index as a CSV file called "data_frame" located in the datasets folder of our workspace.

frame.to_csv('datasets/data_frame.csv')

Let's say you have a pandas DataFrame called "panda" which has 8 rows in total and you want to remove the last row from this DataFrame. Which of these Python commands would you use to do so?

panda.drop(panda.index[7])

In the following Python code, typing which Python command will give the user the CEO of Facebook? import pandas as pd companies_ceo = { 'Amazon' : 'Jeff Bezos' 'Apple' : 'Tim Cook', 'SpaceX': 'Elon Musk' 'Facebook': 'Mark Zuckerberg' 'Netflix': 'Reed Hastings' } companies_ceo_series= pd.Series(companies_ceo)

companies_ceo_series['Facebook'] companies_ceo_series[3]

In the following Python code, typing what command will create a DataFrame called "companies_ceo" whose first column has all the entries of the 'companies' list and whose second column has all the entries of the 'ceo' list, with the column names as the names of the respective variables? import pandas as pd companies = { 'Amazon' 'Apple' 'SpaceX' 'Facebook' 'Netflix' } ceo = { 'Jeff Bezos' 'Tim Cook', 'Elon Musk' 'Mark Zuckerberg' 'Reed Hastings' }

companies_ceo_tuple = list (zip(companies, ceo)) companies_ceo = pd.dataframe(companies_ceo_tuple, columns=['companies', 'ceo'])

Let's say you have saved a dataset in a pandas DataFrame called "dataset" which has tons of records and you only want to access the details of the records in only the 5th, 8th and 14th index. Which of these Python commands can you use to do so?

dataset.loc[5,8,14] dataset.loc[[5,8,14],:]

Match the following statements related to Pandas DataFrames with the correct boolean values.

All the data within a particular column in a Pandas DataFrame must be of the same data type (true) Once a Pandas DataFrame has been created, it is not possible to add a new column to this DataFrame (false) Data in different columns of a Pandas DataFrame cannot be of different data types (false)

Which of these correctly match the following libraries in the Numpy ecosystem with what that library is used for? Data visualization tool used for large datasets Specifically meant for machine learning, data mining, and data analysis Used to perform statistical operations

Bokeh Scikit-learn Statsmodel

Match the following statements related to the concept of multiIndex in Pandas with the correct Boolean values.

MultiIndex is useful when we have large datasets where using numeric indexes to refer to each record is unintuitive (true) The MultiIndex for a row is some composite key made up of exactly one column (false) MultiIndex lets the user effectively store and manipulate higher dimensional data in a 2-dimensional tabular structure (true)

Which of these statements related to the Pandas Series object are true?

Once we create a Pandas Series object, an index representing the positions for each of the data points is automatically created for the list Pandas Series object is similar to a Python list

Which of these statements related to the pivot function in Pandas is true?

The combination of the row index and the column header must be unique in order to generate a pivot table The Pivot function summarizes the details of each column in a DataFrame


संबंधित स्टडी सेट्स

Chapter 2.4.7 Practice Questions

View Set

252-EXM4-CVA/STROKE (PrepU Stroke Exemplar)

View Set

Intercultural Communication competence

View Set

Sec + CertMaster SY0-701 Domain 3 Assessment

View Set

Фармакологія (ЛЗ - МД)

View Set

Unit 6: Biological Reactions and Enzymes questions

View Set

Chapter 4 Eukaryotic Cells and Microorganisms

View Set

Electronic Circuit Symbols: master set

View Set