नोट
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप साइन इन करने या निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
Returns a new DataFrame containing the distinct rows in this DataFrame.
Syntax
distinct()
Returns
DataFrame: DataFrame with distinct records.
Examples
df = spark.createDataFrame(
[(14, "Tom"), (23, "Alice"), (23, "Alice")], ["age", "name"])
df.distinct().show()
# +---+-----+
# |age| name|
# +---+-----+
# | 14| Tom|
# | 23|Alice|
# +---+-----+
df.distinct().count()
# 2
df = spark.createDataFrame(
[(14, "Tom", "M"), (23, "Alice", "F"), (23, "Alice", "F"), (14, "Tom", "M")],
["age", "name", "gender"])
df.distinct().show()
# +---+-----+------+
# |age| name|gender|
# +---+-----+------+
# | 14| Tom| M|
# | 23|Alice| F|
# +---+-----+------+