Raulullah (saws) has said,
"A person is on the creed of his friend. Therefore a person should see who he is affiliated with". (Abu Dawud) In other words, if his friend is pious, he will also be pious, if he is pious, he is sure to be the same. Hence, the irreligiousness of his friend is a cause for his irreligiousness and the piety of his friend is a cause for his piety.This is the gist of this
hadith. A person should ponder over his friendship and contemplate that the person whom I have selected as a friend, in terms of religiousness and piety, is he worth befriending or not?