Just like any big city anywhere in the world the answer to that depends on how you behave yourself and where you go. Use your common sense and be alert not afraid. If it feels wrong, it probably is wrong.
My preference in a big foreign city is always Uber or its equivalent. I feel that Uber tends to be safer than taxis because your ride is tracked on the app and price is always transparent before you are picked up. If you insist on using taxis instead, always make sure you get pricing information for your destination before you get in the car, but don't pay until you arrive. I would not advise renting a car because driving in Mexico City can be very hectic, there is a lot of traffic, and traffic laws and streets are different than in the US, so it is very easy to miss your turn and get lost.