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 filas en este DataFrame, pero no en otro DataFrame.
Sintaxis
subtract(other: "DataFrame")
Parámetros
| Parámetro | Tipo | Descripción |
|---|---|---|
other |
DataFrame | Otro DataFrame que debe restarse. |
Devoluciones
DataFrame: DataFrame restado.
Notas
Esto equivale a EXCEPT DISTINCT en SQL.
Ejemplos
df1 = spark.createDataFrame([("a", 1), ("a", 1), ("b", 3), ("c", 4)], ["C1", "C2"])
df2 = spark.createDataFrame([("a", 1), ("a", 1), ("b", 3)], ["C1", "C2"])
result_df = df1.subtract(df2)
result_df.show()
# +---+---+
# | C1| C2|
# +---+---+
# | c| 4|
# +---+---+
df1 = spark.createDataFrame([(1, "A"), (2, "B")], ["id", "value"])
df2 = spark.createDataFrame([(2, "B"), (3, "C")], ["id", "value"])
result_df = df1.subtract(df2)
result_df.show()
# +---+-----+
# | id|value|
# +---+-----+
# | 1| A|
# +---+-----+