In PySpark, coalesce and repartition are functions used to change the number of partitions in a DataFrame or RDD. coalesce is used to reduce the number of partitions without performing a full shuffle, making it more efficient for decreasing partitions and typically used after filtering data. In contrast, repartition can both increase and decrease the number of partitions by performing a full shuffle of the data, which ensures a balanced distribution across partitions but can be more costly in terms of performance. Thus, coalesce is preferred for reducing partitions efficiently, while repartition is suitable when a balanced and specific number of partitions is needed.