File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
articles/synapse-analytics Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -296,7 +296,7 @@ This will create a temporary view called 'trip_df'.
296
296
SELECT
297
297
*
298
298
FROM
299
- Trip
299
+ trip_df
300
300
```
301
301
302
302
Now you will have the same output as above except the SQL language was used.
@@ -344,14 +344,14 @@ To get a chart like this;
344
344
If you prefer not to use SQL then the same can be achieved with the following PySpark code
345
345
346
346
``` python
347
- %% PySpark
347
+ %% pyspark
348
348
from pyspark.sql import functions as F
349
349
350
- prepped_df = trip_df .select(' TripDistanceMiles' , ' PassengerCount' )\
350
+ prepped_df = data_path .select(' TripDistanceMiles' , ' PassengerCount' )\
351
351
.filter((F.col(" TripDistanceMiles" ) > 0 ) & (F.col(" PassengerCount" ) > 0 ))\
352
- .groupBy(trip_df .PassengerCount)\
352
+ .groupBy(data_path .PassengerCount)\
353
353
.agg(F.sum(F.col(" TripDistanceMiles" )).alias(" SumTripDistance" ),F.avg(F.col(" TripDistanceMiles" )).alias(" AvgTripDistance" ))\
354
- .orderBy(trip_df .PassengerCount)
354
+ .orderBy(data_path .PassengerCount)
355
355
display(prepped_df)
356
356
357
357
```
You can’t perform that action at this time.
0 commit comments