This is what keeps my mind pure and peaceful

This is a very effective way to keep the mind pure and at peace. Here Sage Patanjali talks about the kind of attitude to cultivate for specific kinds of people which will help one to keep their mind undisturbed and pleasant.
First point. Develop friendliness(Maitri) towards happy people(Sukha). If this is not done, usually one develops jealousy towards them. Having a friendly attitude towards them, one develops belongingness and oneness with them, keeping the mind free from the clutch of negativity.
Second point. Have compassion(Karuna) towards the unhappy(Dukha) ones. There is a difference between pity and compassion. Having pity towards someone usually aggravates and fortifies the sadness of the unhappy. Compassion, on the other hand, can be in a form of service towards them to uplift them up. Example, when one says “Oh this shouldn't have happened to you, its very sad that such a trauma has taken place with you”, This is an example of pity. Here the key is not be attached to the unhappy also. Have compassion, with detachment. This way, one is not bound by the guilt of helplessness nor taken away by sadness.
Third point. People who are doing virtuous(Punya) deeds, become complacent(Mudita) towards them. Feel oneness with them, become glad that they are doing good work. When one is not glad about virtuous work happening, generally a criticising attitude overtakes and affect the mind’s serenity. Keep the mind pure by cultivating gladness that there are good people doing virtuous deeds.
Fourth point. Become indifferent(Upekshanam) to wicked(Apunya) people. Educate and ignore is the key. Many times one takes responsibility to change people, especially improve people who are doing vice acts. When they don't change, one gets angry, sad and helpless. Thus, educating once and then move on with indifference is the key to keep the mind at peace.
vishayanam bhavanatah chitta prasadanam
Thus by cultivating such specific attitude regarding those subjects, one’s mind is purified, and remains peaceful.