Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/src/main/python/ml/dataframe_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <input>
bin/spark-submit examples/src/main/python/ml/dataframe_example.py <input_path>
"""
from __future__ import print_function

Expand All @@ -35,18 +35,18 @@
print("Usage: dataframe_example.py <libsvm file>", file=sys.stderr)
sys.exit(-1)
elif len(sys.argv) == 2:
input = sys.argv[1]
input_path = sys.argv[1]
else:
input = "data/mllib/sample_libsvm_data.txt"
input_path = "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 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:")
df.printSchema()
print("Loaded training data as a DataFrame with " +
Expand Down