Filter out empty partitions in apply