Oharra
Baimena behar duzu orria atzitzeko. Direktorioetan saioa has dezakezu edo haiek alda ditzakezu.
Baimena behar duzu orria atzitzeko. Direktorioak alda ditzakezu.
Devuelve un nuevo dataframe que contiene las filas distintas de este dataframe.
Sintaxis
distinct()
Devoluciones
DataFrame: DataFrame con registros distintos.
Ejemplos
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|
# +---+-----+------+