xinrong-meng opened a new pull request, #40539:
URL: https://github.com/apache/spark/pull/40539
### What changes were proposed in this pull request?
Implement CoGrouped Map API: `applyInPandas`.
### Why are the changes needed?
Parity with vanilla PySpark.
### Does this PR introduce _any_ user-facing change?
Yes. CoGrouped Map API is supported as shown below.
```sh
>>> import pandas as pd
>>> df1 = spark.createDataFrame(
... [(20000101, 1, 1.0), (20000101, 2, 2.0), (20000102, 1, 3.0),
(20000102, 2, 4.0)], ("time", "id", "v1"))
>>>
>>> df2 = spark.createDataFrame(
... [(20000101, 1, "x"), (20000101, 2, "y")], ("time", "id", "v2"))
>>>
>>> def asof_join(l, r):
... return pd.merge_asof(l, r, on="time", by="id")
...
>>> df1.groupby("id").cogroup(df2.groupby("id")).applyInPandas(
... asof_join, schema="time int, id int, v1 double, v2 string"
... ).show()
+--------+---+---+---+
| time| id| v1| v2|
+--------+---+---+---+
|20000101| 1|1.0| x|
|20000102| 1|3.0| x|
|20000101| 2|2.0| y|
|20000102| 2|4.0| y|
+--------+---+---+---+
```
### How was this patch tested?
Parity unit tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]