ComenzarEmpieza gratis

Table queries

The courses have launched and students have enrolled—well done! Your final task is to identify high-performing students who recently enrolled and are excelling in their studies to feature in your next campaign. You'll now work with a different dataset, students.csv, which contains information on all students and their grades. The GPA column contains their grade, and the EnrollmentDate column is the date the student enrolled in the course.

The Table, Selection, and LocalDate classes have been imported for you.

Este ejercicio forma parte del curso

Importing Data in Java

Ver curso

Instrucciones del ejercicio

  • Create a Selection for "GPA" greater than 3.5.
  • Create a Selection for enrollment after Jan 1, 2022.
  • Combine both Selection objects.
  • Filter the students table.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

public class StudentAnalysis {
    public static void main(String[] args) {
    	try { 
            Table students = Table.read().csv("students.csv");

            // Create a Selection for GPA greater than 3.5
            Selection highGpa = students.doubleColumn("____").____(3.5);

            // Create a Selection for enrollment after Jan 1, 2022
            Selection freshmen = students.dateColumn("EnrollmentDate")
                .____(LocalDate.of(2022, 1, 1));

            // Combine both Selections
            Selection highPerformingFreshmen = highGpa.____(freshmen);
            
            // Filter the students table
            Table featured = students.____(highPerformingFreshmen);
            
            System.out.println("High-performing freshmen:");
            System.out.println(featured.print());
        } catch (Exception e) {
            System.err.println("Error reading CSV files: " + e.getMessage());
        }
    }
}
Editar y ejecutar código