🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

What is a DataFrame in Python\'s pandas library? A two-dimensional, size-mutable, potentially heterogeneous tabular data structure A one-dimensional array of data A three-dimensional array of data A function to plot graphs New Answer How do you select a column named \'Age\' from a DataFrame df...

What is a DataFrame in Python\'s pandas library? A two-dimensional, size-mutable, potentially heterogeneous tabular data structure A one-dimensional array of data A three-dimensional array of data A function to plot graphs New Answer How do you select a column named \'Age\' from a DataFrame df? df\[\'Age\'\] df.Age() df.get(\'Age\') df.select(\'Age\') New Answer Which method would you use to get the first 5 rows of a DataFrame? df.head() df.tail() df.first() df.top() New Answer Which of the following operations can be performed on a DataFrame? Filtering rows Sorting values Merging with another DataFrame Compiling code New Answer What does the method df.describe() return? Summary statistics of numerical columns All unique values in the DataFrame The shape of the DataFrame A list of column names New Answer Add Category\... How can you add a new column \'Salary\' to a DataFrame df? df\[\'Salary\'\] = \[values\] df.add\_column(\'Salary\', \[values\]) df.insert(\'Salary\', \[values\]) df.append(\'Salary\', \[values\]) New Answer Which method is used to remove missing values from a DataFrame? df.dropna() df.fillna() df.remove\_na() df.clean() New Answer How do you rename a column \'OldName\' to \'NewName\' in a DataFrame df? df.rename(columns={\'OldName\': \'NewName\'}) df.change\_name(\'OldName\', \'NewName\') df.columns\[\'OldName\'\] = \'NewName\' df.update\_column(\'OldName\', \'NewName\') New Answer What will df.shape return for a DataFrame df? A tuple representing the dimensions of the DataFrame The number of columns only The number of rows only The total number of elements New Answer Which of the following methods can be used to iterate over rows in a DataFrame? iterrows() itertuples() iteritems() itercolumns() New Answer How do you filter a DataFrame df to only include rows where the column \'Age\' is greater than 18? df\[df\[\'Age\'\] \> 18\] df.filter(\'Age\' \> 18) df.select(\'Age\' \> 18) df.query(\'Age \> 18\') New Answer What does the method df.info() provide about a DataFrame? A concise summary of the DataFrame, including data types and non-null counts Descriptive statistics of numerical columns The first few rows of the DataFrame A list of unique values in each column New Answer Which function would you use to combine two DataFrames along their columns? pd.concat(\[df1, df2\], axis=1) pd.merge(df1, df2) df1.append(df2) df1.join(df2) New Answer How can you reset the index of a DataFrame df? df.reset\_index() df.set\_index() df.reindex() df.index\_reset() New Answer Which of the following methods can be used to sort a DataFrame by a specific column? df.sort\_values(by=\'column\_name\') df.order\_by(\'column\_name\') df.arrange(\'column\_name\') df.sort(\'column\_name\') New Answer How can you calculate the mean of a column \'Scores\' in a DataFrame df? df\[\'Scores\'\].mean() df.mean(\'Scores\') df.calculate\_mean(\'Scores\') df\[\'Scores\'\].average() New Answer Which method would you use to fill missing values in a DataFrame with a specific value? df.fillna(value) df.replace\_na(value) df.fill(value) df.complete\_missing(value) New Answer How do you drop a column named \'Address\' from a DataFrame df? df.drop(columns=\[\'Address\'\]) df.remove\_column(\'Address\') df.delete(\'Address\') df.drop(\[\'Address\'\]) New Answer How can you rename the index of a DataFrame? df.rename\_axis(\'new\_index\_name\') df.set\_index(\'new\_index\_name\') df.index.rename(\'new\_index\_name\') df.change\_index(\'new\_index\_name\') New Answer Which method would you use to transpose a DataFrame? df.T df.transpose() df.flip() df.switch\_axes() New Answer What is the primary purpose of using a DataFrame in data analysis? To store and manipulate tabular data To create visualizations To compile code To manage databases New Answer How can you check if a DataFrame is empty? df.empty df.is\_empty() len(df) == 0 df.check\_empty() New Answer How do you find the maximum value in a DataFrame column \'Height\'? df\[\'Height\'\].max() df.max(\'Height\') df\[\'Height\'\].maximum() df.find\_max(\'Height\') New Answer Which method would you use to get the unique values of a column \'Category\' in a DataFrame? df\[\'Category\'\].unique() df.unique(\'Category\') df\[\'Category\'\].distinct() df.get\_unique(\'Category\') New Answer What is the purpose of the \'iloc\' method in a DataFrame? To select rows and columns by integer index To select rows based on labels To filter data based on conditions To sort data New Answer Which of the following methods can be used to create a copy of a DataFrame? df.copy() df.duplicate() df.clone() df.deepcopy() df.replicate() New Answer How do you access the last 3 rows of a DataFrame named \'data\'? data.tail(3) data.head(3) data.last(3) data.end(3) New Answer Which of the following operations can be performed using the \'apply\' method? Apply a function along an axis Aggregate data Transform data Filter data New Answer What does the \'axis\' parameter specify in many DataFrame methods? Whether to apply the operation across rows or columns The number of dimensions The sorting order The type of data New Answer Which method would you use to convert a DataFrame to a CSV file? df.to\_csv(\'filename.csv\') df.export\_csv(\'filename.csv\') df.save\_csv(\'filename.csv\') df.write\_csv(\'filename.csv\') New Answer Which of the following methods can be used to visualize data from a DataFrame? df.plot() df.hist() df.visualize() df.show\_plot() df.bar() New Answer How can you remove duplicate rows from a DataFrame? df.drop\_duplicates() df.remove\_duplicates() df.delete\_duplicates() df.clear\_duplicates() New Answer What is the primary function of the \'groupby\' method in pandas? To split data into groups based on some criteria To sort data alphabetically To merge two DataFrames To filter rows based on conditions New Answer How can you replace all occurrences of a specific value in a DataFrame with another value? df.replace(old\_value, new\_value) df.change(old\_value, new\_value) df.update(old\_value, new\_value) df.substitute(old\_value, new\_value) New Answer Which of the following methods can be used to export a DataFrame to an Excel file? df.to\_excel(\'filename.xlsx\') df.write\_excel(\'filename.xlsx\') df.export\_to\_excel(\'filename.xlsx\') df.save\_excel(\'filename.xlsx\') df.to\_csv(\'filename.csv\') New Answer How do you access a subset of a DataFrame using label-based indexing? df.loc\[\] df.iloc\[\] df.at\[\] df.iat\[\] New Answer Which method would you use to remove a specific row from a DataFrame by its index? df.drop(index) df.remove(index) df.delete(index) df.clear(index) New Answer What is the purpose of the \'set\_index\' method in a DataFrame? To set a specific column as the index To reset the index to default To sort the DataFrame by index To remove the index from the DataFrame New Answer How can you find the number of non-null entries in each column of a DataFrame? df.count() df.notnull().sum() df.non\_null\_count() df.valid\_entries() New Answer What is the primary use of the \'head()\' method in a DataFrame? To display the first few rows of the DataFrame To sort the DataFrame To calculate summary statistics To remove duplicate rows New Answer How do you access a specific element in a DataFrame using row and column labels? df.at\[row\_label, column\_label\] df.loc\[row\_label, column\_label\] df.iloc\[row\_index, column\_index\] df.get(row\_label, column\_label) New Answer Which of the following operations can be performed using the \'transform\' method? Apply a function to each group independently Return a transformed version of the original data Filter data based on conditions Sort data by index New Answer How can you change the order of columns in a DataFrame? df = df\[\[\'col2\', \'col1\', \'col3\'\]\] df.reorder\_columns(\[\'col2\', \'col1\', \'col3\'\]) df.sort\_columns(\[\'col2\', \'col1\', \'col3\'\]) df.arrange\_columns(\[\'col2\', \'col1\', \'col3\'\]) New Answer Which of the following methods can be used to fill missing values in a DataFrame with the mean of the column? df.fillna(df.mean()) df.replace\_na(df.mean()) df.fill\_missing(df.mean()) df.impute\_mean() New Answer What is the primary advantage of using a DataFrame over a regular Python list? DataFrames allow for labeled data manipulation DataFrames are faster than lists in all operations DataFrames can only store numerical data DataFrames automatically visualize data New Answer Which method would you use to check the data type of each column in a DataFrame? df.dtypes df.types() df.column\_types() df.check\_dtypes() New Answer Which of the following methods can be used to concatenate two DataFrames horizontally? pd.concat(\[df1, df2\], axis=1) df1.join(df2) df1.append(df2) pd.merge(df1, df2) New Answer How do you calculate the sum of all elements in a DataFrame? df.sum().sum() df.total\_sum() df.calculate\_sum() df.aggregate\_sum() New Answer How can you add a new row to an existing DataFrame? df.loc\[len(df)\] = \[values\] df.add\_row(\[values\]) df.insert\_row(\[values\]) df.append\_row(\[values\]) New Answer Which of the following methods can be used to perform element-wise multiplication of two DataFrames? df1 \* df2 df1.mul(df2) df1.multiply(df2) df1.elementwise\_mult(df2)

Use Quizgecko on...
Browser
Browser