The question was about Mexico City, not the beach cities or resorts. Mexico City is very much like New York City and Los Angeles, very rich areas, very poor areas, skyscrapers and suburbs. Mexico City and New York are pretty much the same size too. There are many places in Mexico City that would be best to avoid, but that is true for LA and NYC too. I've traveled throughout Mexico City via subway and bus, and have walked through the central city even late at night without any fear. Use common sense, don't wear overly expensive clothes, and you'll be fine.