Bruce P. Majors, in his blog.
Many parts of DC are safe beyond the areas I will list here, but why chance it if you don't know where you are?Matt Yglesias observes "Five years ago I would have said definitively that the most terrifying thing about the Green/Yellow lines is the black people, but more recently this may be a caution against interacting with hipsters."
If you are on the subway stay on the Red line between Union Station and Shady Grove, Maryland. If you are on the Blue or Orange line do not go past Eastern Market (Capitol Hill) toward the Potomac Avenue stop and beyond; stay in NW DC and points in Virginia. Do not use the Green line or the Yellow line. These rules are even more important at night. There is of course nothing wrong with many other areas; but you don't know where you are, so you should not explore them.
If on foot or in a cab or bus, stay in Bethesda, Arlington (preferably north Arlington), Crystal City, Falls Church, Annandale, or Alexandria, or in DC only in northwest DC west (i.e. larger street numbers) of 14th or 16th streets, or if on Capitol Hill only in SE Capitol Hill (zip 20003) between 1st and 8th Streets, not farther out than 8th (e.g. 9th, 10th etc). (Or stay on the Mall and at the various monuments.) Again there are many other lovely places, from the Catholic University of America to Silver Spring, Maryland. But you don't know where you are so you cannot go, especially at night, unless you take me with you.
Personally I consider this a bit of a cautionary tale about well-meant advice on places to avoid in cities. I spend a lot of my time wandering around big cities looking for things to eat, driving, walking, or on transit. There's a lot of advice like this floating around the web, in guidebooks, and even given out by people in hotels and guesthouses, and it's important to remember whenever you get advice that it reflects the assumptions and fears of the people giving it. It's often difficult to gauge how reasonable it is, particularly if you're not used to cities in general as well as the specific city in question.