concept year in category spark

appears as: year, year, years, years
Spark in Action, Second Edition

This is an excerpt from Manning's book Spark in Action, Second Edition.

Transformations are operations you perform on data, such as extracting a year from a date, combining two fields, normalizing data, and so on. In this chapter, you’ll learn how to use dataframe-specific functions to perform transformations, as well as methods directly attached to the dataframe API. You will merge two dataframes into one by using a SQL union-like operation. You’ll also see the difference between a dataset and a dataframe, and how to go from one to the other.

Listing 15.15 Evolution of enrollment in NYC schools
... YorkSchoolStatisticsApp.java:93 ): Evolution of # of students per year
+----------+--------+
|schoolYear|enrolled|
+----------+--------+
| 2006     | 994597 |
| 2007     | 978064 |
| 2008     | 976091 |
| 2009     | 987968 |
| 2010     | 990097 |
| 2011     | 990235 |
| 2012     | 986900 |
| 2013     | 985040 |
| 2014     | 983189 |
...
... YorkSchoolStatisticsApp.java:100 ): 2006 was the year with most students,
  ➥ the district served 994597 students.

To build this aggregated dataset, you can start from the previous question, which contains the school ID, the school year, and the average enrollment per year.

To find out the maximum value, simply set the enrolled column in descending order, take the first row, and get the values. Remember that, in this lab, the year is a string. Columns start at 0.