PySpark Certification Practice Test 08
Predict The Output Questions
PySpark Certification Practice Test 08
Predict The Output Questions
Insightful Saga — Modern Data Engineering Certification Preparation
Question 141
Input Data: | id | |----| | 1 | | 2 | | 3 | Code: ```python df.count() ``` What will be returned?
Question 142
Input Data: | country | |----------| | India | | India | | USA | Code: ```python df.select("country").distinct().count() ``` Output?
Question 143
Input Data: | id | salary | |----|--------| | 1 | 1000 | | 2 | 5000 | | 3 | 2000 | Code: ```python df.filter(col("salary") > 2000).count() ``` Output?
Question 144
Input Data: | id | |----| | 1 | | 1 | | 2 | Code: ```python df.dropDuplicates().count() ``` Output?
Question 145
Input Data: | amount | |---------| | 100 | | 200 | | 300 | Code: ```python df.agg(sum("amount")) ``` Result?
Question 146
Input Data: | amount | |---------| | 100 | | 200 | | 300 | Code: ```python df.agg(avg("amount")) ``` Result?
Question 147
Input Data: | id | |----| | 1 | | 2 | | 3 | Code: ```python df.limit(2).count() ``` Output?
Question 148
Input Data: | value | |--------| | NULL | | 100 | Code: ```python df.fillna(0) ``` NULL value becomes?
Question 149
Input Data: sales_df | id | |----| | 1 | | 2 | customer_df | id | |----| | 2 | | 3 | Inner Join Row Count?
Question 150
Same Data Left Join Row Count?
Question 151
Input Data: | salary | |--------| | 1000 | | 1000 | | 2000 | Code: ```python rank() ``` Ordered by salary descending. Ranks?
Question 152
Using same input: ```python dense_rank() ``` Output?
Question 153
Input Data: | salary | |--------| | 1000 | | 2000 | | 3000 | Code: ```python lag("salary") ``` For salary = 2000 Returned value?
Question 154
Input Data: | salary | |--------| | 1000 | | 2000 | | 3000 | Code: ```python lead("salary") ``` For salary = 2000 Returned value?
Question 155
Input Data: | value | |-------| | A | | B | | C | Code: ```python row_number() ``` Order By value Output?
Question 156
Input Data: | amount | |--------| | 100 | | 200 | | 300 | Running Total Output?
Question 157
Input Data: | id | |----| | 1 | | 2 | Code: ```python df.union(df) ``` Row Count?
Question 158
Input Data: | id | |----| | 1 | | 2 | | 3 | Code: ```python df.filter(col("id") > 1) ``` Returned ids?
Question 159
Input Data: | amount | |--------| | 100 | | 200 | | 300 | Code: ```python df.orderBy(desc("amount")) ``` First row?
Question 160
Input Data: | customer_id | amount | |-------------|--------| | C1 | 100 | | C1 | 200 | | C2 | 300 | Code: ```python df.groupBy("customer_id").agg(sum("amount")) ``` How many output rows?
### Explanation Aggregation returns one row per group. Since there are two unique customers (C1 and C2), the output contains two rows. --- PySpark Certification Practice Test 09 Questions 161-180 Complete the Logic / Best Coding Solution