Is there a way to conditionally apply filter to a window function in pyspark? For every group in col1 I want to keep only rows that have X in col2. If a group doesn't have X in col2 I want to keep all rows in that group.
+------+------+
| col1 | col2 |
+------+------+
| A | |
+------+------+
| A | X |
+------+------+
| A | |
+------+------+
| B | |
+------+------+
| B | |
+------+------+
| B | |
+------+------+