From 4685d68f230fa166044303ca499d9513eb2bab57 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Tue, 6 Mar 2018 11:01:19 -0300 Subject: [PATCH 1/3] Changes input variable to not conflict with reserved word Signed-off-by: DylanGuedes --- examples/src/main/python/ml/dataframe_example.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/src/main/python/ml/dataframe_example.py b/examples/src/main/python/ml/dataframe_example.py index d62cf2338a1fe..65acbc580a793 100644 --- a/examples/src/main/python/ml/dataframe_example.py +++ b/examples/src/main/python/ml/dataframe_example.py @@ -17,7 +17,7 @@ """ An example of how to use DataFrame for ML. Run with:: - bin/spark-submit examples/src/main/python/ml/dataframe_example.py + bin/spark-submit examples/src/main/python/ml/dataframe_example.py """ from __future__ import print_function @@ -35,18 +35,18 @@ print("Usage: dataframe_example.py ", file=sys.stderr) sys.exit(-1) elif len(sys.argv) == 2: - input = sys.argv[1] + dataset = sys.argv[1] else: - input = "data/mllib/sample_libsvm_data.txt" + dataset = "data/mllib/sample_libsvm_data.txt" spark = SparkSession \ .builder \ .appName("DataFrameExample") \ .getOrCreate() - # Load input data - print("Loading LIBSVM file with UDT from " + input + ".") - df = spark.read.format("libsvm").load(input).cache() + # Load dataset + print("Loading LIBSVM file with UDT from " + dataset + ".") + df = spark.read.format("libsvm").load(dataset).cache() print("Schema from LIBSVM:") df.printSchema() print("Loaded training data as a DataFrame with " + From 2cb9b570c4057add5cd1ce4492a0db3bd70d8e8c Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 9 Mar 2018 09:49:40 -0300 Subject: [PATCH 2/3] Uses input_path name instead Signed-off-by: DylanGuedes --- examples/src/main/python/ml/dataframe_example.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/src/main/python/ml/dataframe_example.py b/examples/src/main/python/ml/dataframe_example.py index 65acbc580a793..9823c2c9f9f99 100644 --- a/examples/src/main/python/ml/dataframe_example.py +++ b/examples/src/main/python/ml/dataframe_example.py @@ -17,7 +17,7 @@ """ An example of how to use DataFrame for ML. Run with:: - bin/spark-submit examples/src/main/python/ml/dataframe_example.py + bin/spark-submit examples/src/main/python/ml/dataframe_example.py """ from __future__ import print_function @@ -35,18 +35,18 @@ print("Usage: dataframe_example.py ", file=sys.stderr) sys.exit(-1) elif len(sys.argv) == 2: - dataset = sys.argv[1] + input_path = sys.argv[1] else: - dataset = "data/mllib/sample_libsvm_data.txt" + input_path = "data/mllib/sample_libsvm_data.txt" spark = SparkSession \ .builder \ .appName("DataFrameExample") \ .getOrCreate() - # Load dataset - print("Loading LIBSVM file with UDT from " + dataset + ".") - df = spark.read.format("libsvm").load(dataset).cache() + # Load file from path + print("Loading LIBSVM file with UDT from " + input_path + ".") + df = spark.read.format("libsvm").load(input_path).cache() print("Schema from LIBSVM:") df.printSchema() print("Loaded training data as a DataFrame with " + From ae97cebfaf44c60b92285351f2bc83f80c19633a Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 9 Mar 2018 10:17:14 -0300 Subject: [PATCH 3/3] Changes load file comment Signed-off-by: DylanGuedes --- examples/src/main/python/ml/dataframe_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/main/python/ml/dataframe_example.py b/examples/src/main/python/ml/dataframe_example.py index 9823c2c9f9f99..cabc3de68f2f4 100644 --- a/examples/src/main/python/ml/dataframe_example.py +++ b/examples/src/main/python/ml/dataframe_example.py @@ -44,7 +44,7 @@ .appName("DataFrameExample") \ .getOrCreate() - # Load file from path + # Load an input file print("Loading LIBSVM file with UDT from " + input_path + ".") df = spark.read.format("libsvm").load(input_path).cache() print("Schema from LIBSVM:")