4
4
"cell_type" : " markdown" ,
5
5
"metadata" : {
6
6
"application/vnd.databricks.v1+cell" : {
7
- "cellMetadata" : {},
7
+ "cellMetadata" : {
8
+ "byteLimit" : 2048000 ,
9
+ "rowLimit" : 10000
10
+ },
8
11
"inputWidgets" : {},
9
12
"nuid" : " db7ebec7-889d-4791-9b66-269554c0d581" ,
10
13
"showTitle" : false ,
21
24
"execution_count" : 0 ,
22
25
"metadata" : {
23
26
"application/vnd.databricks.v1+cell" : {
24
- "cellMetadata" : {},
27
+ "cellMetadata" : {
28
+ "byteLimit" : 2048000 ,
29
+ "rowLimit" : 10000
30
+ },
25
31
"inputWidgets" : {},
26
32
"nuid" : " 70352d4b-6bb2-42f3-8465-ba88ab41d730" ,
27
33
"showTitle" : false ,
40
46
"cell_type" : " markdown" ,
41
47
"metadata" : {
42
48
"application/vnd.databricks.v1+cell" : {
43
- "cellMetadata" : {},
49
+ "cellMetadata" : {
50
+ "byteLimit" : 2048000 ,
51
+ "rowLimit" : 10000
52
+ },
44
53
"inputWidgets" : {},
45
54
"nuid" : " 154313e3-f403-4508-a1d1-a93ae1e178d9" ,
46
55
"showTitle" : false ,
102
111
"execution_count" : 0 ,
103
112
"metadata" : {
104
113
"application/vnd.databricks.v1+cell" : {
105
- "cellMetadata" : {},
114
+ "cellMetadata" : {
115
+ "byteLimit" : 2048000 ,
116
+ "rowLimit" : 10000
117
+ },
106
118
"inputWidgets" : {},
107
119
"nuid" : " 787ef081-e08b-4a47-9b9a-a1a07b8b2b93" ,
108
120
"showTitle" : false ,
123
135
" survey_log_df_578 = spark.createDataFrame(survey_log_data_578, survey_log_columns_578)\n " ,
124
136
" survey_log_df_578.show()\n "
125
137
]
138
+ },
139
+ {
140
+ "cell_type" : " code" ,
141
+ "execution_count" : 0 ,
142
+ "metadata" : {
143
+ "application/vnd.databricks.v1+cell" : {
144
+ "cellMetadata" : {
145
+ "byteLimit" : 2048000 ,
146
+ "rowLimit" : 10000
147
+ },
148
+ "inputWidgets" : {},
149
+ "nuid" : " 8448776c-e90d-429d-ba0d-00c46d06099f" ,
150
+ "showTitle" : false ,
151
+ "tableResultSettingsMap" : {},
152
+ "title" : " "
153
+ }
154
+ },
155
+ "outputs" : [],
156
+ "source" : [
157
+ " answer_counts_df_578 = survey_log_df_578\\\n " ,
158
+ " .filter(col(\" action\" ) == 'answer')\\\n " ,
159
+ " .groupBy(\" question_id\" )\\\n " ,
160
+ " .agg(count('action').alias(\" answer_count\" ))\n " ,
161
+ " \n " ,
162
+ " show_counts_df_578 = survey_log_df_578\\\n " ,
163
+ " .filter(col(\" action\" ) == \" show\" )\\\n " ,
164
+ " .groupBy(\" question_id\" )\\\n " ,
165
+ " .agg(count('action').alias(\" show_count\" ))\n " ,
166
+ " \n " ,
167
+ " answer_rates_df_578 = show_counts_df_578\\\n " ,
168
+ " .join(answer_counts_df_578, show_counts_df_578.question_id == answer_counts_df_578.question_id, 'left')\\\n " ,
169
+ " .withColumn(\" answer_rate\" , when(col(\" answer_count\" ).isNull(),0.0)\\\n " ,
170
+ " .otherwise(col('answer_count')/col('show_count')))\\\n " ,
171
+ " .select(show_counts_df_578[\" question_id\" ], \" answer_rate\" )\n " ,
172
+ " \n " ,
173
+ " window_spec = Window.orderBy(col(\" answer_rate\" ).desc(), col(\" question_id\" ).asc())\n " ,
174
+ " ranked_df_578 = answer_rates_df_578.withColumn(\" rank\" , rank().over(window_spec))\n " ,
175
+ " \n " ,
176
+ " ranked_df_578\\\n " ,
177
+ " .filter(col(\" rank\" ) == 1)\\\n " ,
178
+ " .select(\" question_id\" ).show()"
179
+ ]
126
180
}
127
181
],
128
182
"metadata" : {
129
183
"application/vnd.databricks.v1+notebook" : {
130
- "computePreferences" : null ,
184
+ "computePreferences" : {
185
+ "hardware" : {
186
+ "accelerator" : null ,
187
+ "gpuPoolId" : null ,
188
+ "memory" : null
189
+ }
190
+ },
131
191
"dashboards" : [],
132
192
"environmentMetadata" : {
133
193
"base_environment" : " " ,
134
- "environment_version" : " 1 "
194
+ "environment_version" : " 2 "
135
195
},
136
196
"inputWidgetPreferences" : null ,
137
197
"language" : " python" ,
138
198
"notebookMetadata" : {
139
199
"pythonIndentUnit" : 4
140
200
},
141
- "notebookName" : " 578. Get Highest Answer Rate Question (Medium)" ,
201
+ "notebookName" : " 578. Get Highest Answer Rate Question (Medium)-(Solved) " ,
142
202
"widgets" : {}
203
+ },
204
+ "language_info" : {
205
+ "name" : " python"
143
206
}
144
207
},
145
208
"nbformat" : 4 ,
146
209
"nbformat_minor" : 0
147
- }
210
+ }
0 commit comments