CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Importing Data in Java

Afficher le cours

Instructions

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

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

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());
        }
    }
}
Modifier et exécuter le code