LoslegenKostenlos loslegen

Initial data exploration

You're a new data analyst at TechCorp. HR needs a focused view of high earners for budget planning, but the full employee table has dozens of columns. Selecting only relevant columns reduces noise and makes your analysis clearer for you and stakeholders reviewing your results.

The Table and related Tablesaw classes have been imported for you.

Diese Übung ist Teil des Kurses

Importing Data in Java

Kurs anzeigen

Anleitung zur Übung

  • Select columns: "Name", "Department", "JobTitle", "Salary", "Age".
  • Filter for salaries above $60,000.
  • Sort by salary descending.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

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

            // Select the essential columns
            Table essentialData = employees.____("Name", "Department", "JobTitle", "Salary", "Age");

            // Filter for salaries above $60,000
            Table highEarners = essentialData.____(
                essentialData.intColumn("____").____(60000));

            // Sort by salary descending
            Table sortedHighEarners = highEarners.____("____");

            System.out.println("Top 10 Highest Earning Employees:");
            System.out.println(sortedHighEarners.first(10));
		} catch (Exception e) {
            System.err.println("Error reading CSV files: " + e.getMessage());
        }
    }
}
Code bearbeiten und ausführen