It means what it says. And Jesus Christ himself is a great example.
Luke 6:27-28
"But I tell you who hear me: Love your enemies, do good to those who hate you, 28bless those who curse you, pray for those who mistreat you.
It is very hard to do this, but it is good for our bodies and for our souls. We only hurt ourselves and our health by hating those who mistreat us and by holding grudges.
We must forgive them, pray for them, love them, do good things for them if there is an opportunity, but we do not have to associate with them. There are certain people in this world that we are not supposed to associate with, even if they go to church and even if they are Christians:
1 Corinthians 5:10-11
not at all meaning the people of this world who are immoral, or the greedy and swindlers, or idolaters. In that case you would have to leave this world. 11But now I am writing you that you must not associate with anyone who calls himself a brother but is sexually immoral or greedy, an idolater or a slanderer, a drunkard or a swindler. With such a man do not even eat.
1 Corinthians 15:33
Do not be misled: "Bad company corrupts good character."
2 Thessalonians 3:14-15
If anyone does not obey our instruction in this letter, take special note of him. Do not associate with him, in order that he may feel ashamed. 15Yet do not regard him as an enemy, but warn him as a brother.