From where do we know that one must be "dan" someone "l'caf zechut"? (that we must judge someone favorably even though from a certain act it might seem they are doing something?
The Gemora (Shavuos 30a) derives from the verse (Vayikra 19:15) "בצדק תשפוט עמיתך" ("You shall judge your fellow with righteousness") that one should judge others favorably.
In Pirkei Avos 1:7:
יהושע בן פרחיה אומר, עשה לך רב, וקנה לך חבר יג, והוי דן את כל האדם לכף זכות.
Joshua the son of Perachia would say: Assume for yourself a master, acquire for yourself a friend, and judge every man to the side of merit.