org.apache.spark.sql.DataFrame.select()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(270)

本文整理了Java中org.apache.spark.sql.DataFrame.select()方法的一些代码示例,展示了DataFrame.select()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataFrame.select()方法的具体详情如下:
包路径:org.apache.spark.sql.DataFrame
类名称:DataFrame
方法名:select

DataFrame.select介绍

暂无

代码示例

代码示例来源:origin: amidst/toolbox

private static ArrayList<String> getColumnStates(DataFrame data, String name) {
  ArrayList<String> states = new ArrayList();
  final Row[] statesRow = data.select(name).distinct().collect();
  for (Row r : statesRow)
    states.add( r.getString(0) );
  return states;
}

代码示例来源:origin: stackoverflow.com

import org.apache.spark.api.java.*;
import org.apache.spark.SparkConf;
import org.apache.spark.sql.SQLContext;
import static org.apache.spark.sql.functions.*;
import org.apache.spark.sql.DataFrame;

public class App {
  public static void main(String[] args) {
    SparkConf conf = new SparkConf().setMaster("local");
    JavaSparkContext sc = new JavaSparkContext(conf);
    SQLContext sqlContext= new SQLContext(sc);

    DataFrame df = sqlContext.sql(
      "SELECT CAST('2012-01-01' AS DATE), CAST('2013-08-02' AS DATE)").toDF("first", "second");
    df.select(datediff(df.col("first"), df.col("second"))).show();
  }
}

代码示例来源:origin: stackoverflow.com

df.select("C").collect();
} catch(Exception e) {
  System.out.println("Failed to C for " + version);
  df.select("A.D").collect();
} catch(Exception e) {
  System.out.println("Failed to A.D for " + version);

代码示例来源:origin: stackoverflow.com

DataFrame personPositions = persons.select(persons.col("fullName").as("personName"),
    org.apache.spark.sql.functions.explode(persons.col("positions")).as("pos"));
 DataFrame test = personPositions.select(personPositions.col("personName"),
 personPositions.col("pos").getField("companyName").as("companyName"), personPositions.col("pos").getField("title").as("positionTitle"));

代码示例来源:origin: stackoverflow.com

for (Row r: results.select("features", "label", "myProbability", "prediction").collect()) {
  System.out.println("(" + r.get(0) + ", " + r.get(1) + ") -> prob=" + r.get(2)
      + ", prediction=" + r.get(3));

代码示例来源:origin: phuonglh/vn.vitk

String dataPath = new Path(path, "data").toString();
DataFrame df = sqlContext().read().format("parquet").load(dataPath);
Row row = df.select("markovOrder", "weights", "tagDictionary").head();

代码示例来源:origin: phuonglh/vn.vitk

DataFrame df0 = (new SQLContext(jsc)).createDataFrame(jrdd, WhitespaceContext.class);
DataFrame df1 = model.transform(df0);
prediction = jsc.broadcast(df1.select("prediction").collect());
if (df1.count() > 0) {
  output = s.map(new WhitespaceClassificationFunction());

代码示例来源:origin: phuonglh/vn.vitk

DataFrame predictionAndLabel = result.select("prediction", "label");
MulticlassClassificationEvaluator evaluator = new MulticlassClassificationEvaluator().setMetricName("precision");
if (verbose) {

代码示例来源:origin: phuonglh/vn.vitk

JavaRDD<Row> wt = df.select("word", "label").javaRDD();
JavaPairRDD<String, Set<Integer>> tagDictionary = wt.mapToPair(new PairFunction<Row, String, Set<Integer>>(){
  private static final long serialVersionUID = 5865372074294028547L;

代码示例来源:origin: phuonglh/vn.vitk

df.select("dependency").write().text(outputFileName);
else 
  df.repartition(1).write().json(outputFileName);

相关文章