41. What is file handling in Python? What are the various file-handling operations in Python? File handling is a technique that handles file operations such as the process of opening, reading, writing, and manipulating files on the file system. Python File Handling Operations can be categorized...
Handling Indexes Aligns DataFrames based on keys Can choose to ignore or preserve indexes Result Single DataFrame with combined data Single DataFrame with stacked data 23. How do you convert categorical values in a column into numerical ones? To convert categorical values into numerical ones in a ...
In Spark, the Catalyst optimizer is a rule-based component of Spark SQL used to optimize query performance. Its main task is to transform and improve the user’s SQL or DataFrame operation to generate an efficient physical execution plan tailored to the specific query and dataset characteristics....
You can use split() function to split a string based on a delimiter to a list of strings. You can use join() function to join a list of strings based on a delimiter to give a single string. string = "This is a string." string_list = string.split(' ') #delimiter is ‘space’...
candidate's ability to use Python data structures (strings, lists, dictionaries, tuples), manage files, handle exceptions and structure code using Object-Oriented Programming principles. The Python coding assessment uses code-tracing and scenario-based MCQ questions to evaluate hands-on Python coding ...
for i in range(5): yield i gen = gen_numbers() print(next(gen)) # 0 print(next(gen)) # 1 21. Explain Python’s with statement. Answer: The with statement is used for resource management, ensuring proper acquisition and release of resources like file handling. ...
1)HDFS – Hadoop Distributed File System is the java based file system for scalable and reliable storage of large datasets. Data in HDFS is stored in the form of blocks and it operates on the Master-Slave Architecture. 2)Hadoop MapReduce-This is a java based programming paradigm of the Had...
Python Questions and Answers – Exception Handling – 2 This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Exception Handling – 2”.1. The following Python code will result in an error if the input value is entered as -5....
16. How do you sort a DataFrame based on columns? We have the sort_values() method to sort the DataFrame based on a single column or multiple columns. Syntax:df.sort_values(by=[“column_names”]) Example code: importpandasaspd
Question 7: Which of the following are valid uses of the Exception class in Python? (Choose all that apply) Catching general exceptions to prevent program crashes. Raising it explicitly using the raise statement. Handling system-level events like SystemExit. ...