The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
 "Thanks to the groom," etc.--This story the Master told while staying in Veḷuvana Park, about keeping bad company. The circumstances have been already recounted under the Mahilāmukha Jātaka 1. Again, as before, the Master said: "In former days this Brother kept bad company just as he does now." Then he told an old story.
Once upon a time, there was a king named Sāma, the Black, reigning in Benares. In those days the Bodhisatta was one of a courtier's family, and grew up to be the king's temporal and spiritual adviser. Now the king had a state horse named Paṇḍava, and one Giridanta was his trainer, a lame man. The horse used to watch him as he tramped on and on in front, holding the halter; and knowing him to be his trainer, imitated him and limped too.
Somebody told the king how the horse was limping. The king sent surgeons. They examined the horse, but found him perfectly sound; and so accordingly made report. Then the king sent the Bodhisatta. "Go, friend," said he, "and find out all about it." He soon found out that the horse was lame because he went about with a lame trainer. So he told the king what it was. "It's a case of bad company," said he, and went on to repeat the first stanza:--
"Well, now, my friend," said the king, "what's to be done?" "Get a good groom," replied the Bodhisatta, "and the horse will be as good as ever." Then he repeated the second stanza:--
The king did so. The horse became as good as before. The king showed great honour to the Bodhisatta, being pleased that he knew even the ways of animals.
The Master, when this discourse was ended, identified the Birth:--"Devadatta was Giridanta in those days; the Brother who keeps bad company was the horse; and the wise counsellor was I myself."
67:1 No. 26.