本文整理汇总了Java中tech.tablesaw.api.Table.selectWhere方法的典型用法代码示例。如果您正苦于以下问题:Java Table.selectWhere方法的具体用法?Java Table.selectWhere怎么用?Java Table.selectWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tech.tablesaw.api.Table
的用法示例。
在下文中一共展示了Table.selectWhere方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Table table = Table.read().csv("../data/tornadoes_1950-2014.csv");
Table t2 = table.countBy(table.categoryColumn("State"));
t2 = t2.selectWhere(column("Count").isGreaterThan(100));
show("tornadoes by state", t2.categoryColumn("Category"), t2.nCol("Count"));
show("T", table.summarize("fatalities", sum).by("Scale"));
}
示例2: main
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Table ops = Table.create("../data/operations.csv");
out(ops.structure());
out(ops);
DateTimeColumn start = ops.dateColumn("Date").atTime(ops.timeColumn("Start"));
DateTimeColumn end = ops.dateColumn("Date").atTime(ops.timeColumn("End"));
for (int row : ops) {
if (ops.timeColumn("End").get(row).isBefore(ops.timeColumn("Start").get(row))) {
end.get(row).plusDays(1);
}
}
// Calc duration
LongColumn duration = start.differenceInSeconds(end);
ops.addColumn(duration);
duration.setName("Duration");
out(ops);
Table q2_429_assembly = ops.selectWhere(
allOf
(column("date").isInQ2(),
(column("SKU").startsWith("429")),
(column("Operation").isEqualTo("Assembly"))));
Table durationByFacilityAndShift = q2_429_assembly.median("Duration").by("Facility", "Shift");
out(durationByFacilityAndShift);
durationByFacilityAndShift.write().csv("/tmp/durationByFacilityAndShift.csv");
}
示例3: main
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// Get the data
Table baseball = Table.read().csv("../data/baseball.csv");
out(baseball.structure());
// filter to the data available in the 2002 season
Table moneyball = baseball.selectWhere(column("year").isLessThan(2002));
// plot regular season wins against year, segregating on whether the team made the plays
NumericColumn wins = moneyball.numericColumn("W");
NumericColumn year = moneyball.numericColumn("Year");
Column playoffs = moneyball.column("Playoffs");
Scatter.show("Regular season wins by year", wins, year, moneyball.splitOn(playoffs));
// Calculate the run difference for use in the regression model
IntColumn runDifference = moneyball.shortColumn("RS").subtract(moneyball.shortColumn("RA"));
moneyball.addColumn(runDifference);
runDifference.setName("RD");
// Plot RD vs Wins to see if the relationship looks linear
Scatter.show("RD x Wins", moneyball.numericColumn("RD"), moneyball.numericColumn("W"));
// Create the regression model
//ShortColumn wins = moneyball.shortColumn("W");
LeastSquares winsModel = LeastSquares.train(wins, runDifference);
out(winsModel);
// Make a prediction of how many games we win if we score 135 more runs than our opponents
double[] testValue = new double[1];
testValue[0] = 135;
double prediction = winsModel.predict(testValue);
out("Predicted wins with RD = 135: " + prediction);
// Predict runsScored based on On-base percentage, batting average and slugging percentage
LeastSquares runsScored = LeastSquares.train(moneyball.nCol("RS"),
moneyball.nCol("OBP"), moneyball.nCol("BA"), moneyball.nCol("SLG"));
out(runsScored);
LeastSquares runsScored2 = LeastSquares.train(moneyball.nCol("RS"),
moneyball.nCol("OBP"), moneyball.nCol("SLG"));
out(runsScored2);
Histogram.show(runsScored2.residuals());
Scatter.fittedVsResidual(runsScored2);
Scatter.actualVsFitted(runsScored2);
// We use opponent OBP and opponent SLG to model the efficacy of our pitching and defence
Table moneyball2 = moneyball.selectWhere(column("year").isGreaterThan(1998));
LeastSquares runsAllowed = LeastSquares.train(moneyball2.nCol("RA"),
moneyball2.nCol("OOBP"), moneyball2.nCol("OSLG"));
out(runsAllowed);
}
示例4: main
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Table table = Table.read().csv("../data/tornadoes_1950-2014.csv");
table = table.selectWhere(column("Fatalities").isGreaterThan(3));
Pareto.show("Tornado Fatalities by State", table.summarize("fatalities", sum).by("State"));
}
示例5: main
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out("");
out("Some Examples: ");
// Read the CSV file
ColumnType[] types = {INTEGER, CATEGORY, CATEGORY, FLOAT, FLOAT};
Table table = Table.read().csv(CsvReadOptions.builder("../data/bus_stop_test.csv").columnTypes(types));
// Look at the column names
out(table.columnNames());
// Peak at the data
out(table.first(5));
// Remove the description column
table.removeColumns("stop_desc");
// Check the column names to see that it's gone
out(table.columnNames());
// Take a look at some data
out("In 'examples. Printing first(5)");
out(table.first(5));
// Lets take a look at the latitude and longitude columns
// out(table.realColumn("stop_lat").rowSummary().out());
out(table.floatColumn("stop_lat").summary());
// Now lets fill a column based on data in the existing columns
// Apply the map function and fill the resulting column to the original table
// Lets filtering out some of the rows. We're only interested in records with IDs between 524-624
Table filtered = table.selectWhere(QueryHelper.column("stop_id").isBetweenIncluding(524, 624));
out(filtered.first(5));
// Write out the new CSV file
CsvWriter.write(filtered, "../data/filtered_bus_stops.csv");
}