Map from Google - Mexico_City

In Mexico City, the huge federal capital of Mexico, the climate is subtropical, mild or pleasantly warm during the day, with cool nights in summer and cold nights in winter. In fact, the daily temperature range is remarkable, especially in the dry season.
The city is located at a tropical latitude, but at an altitude varying between 7,200 and 8,500 feet, in the so-called tierras frìas.
Here are the average temperatures.
Average temperatures - Mexico City
Mexico CityJanFebMarAprMayJunJulAugSepOctNovDec
Min (°F)434548525454545454504645
Max (°F)707379818177737372727270

Rainfall is concentrated in the summer months: it exceeds 4 inches per month from June to September, it's moderate in May and October, and scarce in the other months. Typically the rains occur in the form of showers in the afternoon or evening, and when they are abundant they can make it difficult getting around. The dry season is long, going from November to April. The total annual rainfall is around 21.5/25.5 inches per year in the eastern districts, while it increases in the western districts, up to 40 inches per year in the neighborhood called Bosques de las Lomas, which is located at the foot of mountains, more than 10,000 feet high and able to enhance the summer rains.
Here is the average precipitation.
Average precipitation - Mexico City
Mexico CityJanFebMarAprMayJunJulAugSepOctNovDecYear
Prec. (in)

The amount of sunshine is never good, because the weather can remain variable or cloudy even during the dry winter period, however, it's acceptable in winter and spring, before the summer rains, while cloudiness is frequent and widespread in summer. The pall of pollution that hangs over the city makes the sky often veiled and the air hazy. Anyway, because the city is located at high altitudes, its tropical sun is very strong, especially when it is highest above the horizon around noon, ie from April to August.

In winter, from November to February, it's cold at night, while daytime temperatures are pleasant. In the city the "urban heat island effect" reduces the overnight cooling, but in the countryside and in the less urbanized neighborhoods the temperature can get to the freezing point. Already in February the daytime temperatures begin to rise, often exceeding 77 °F. It hardly ever rains. Sometimes there can be wind days, which have the advantage of cleaning the air.

Spring is the warmest season, at least during the day, thanks to the higher amount of sunshine. In April and May the temperature often touches 85 °F; at night, however, it can still be a bit cold. In May, the first rains begin.

Summer, from June to September, is the wettest season: rain showers occur almost daily, although they are rarely abundant. The weather is mild, and the temperature range is reduced compared with the previous months: the daytime temperatures are virtually the same as in winter, while at night they are cool but not cold.

Autumn is short: in October, a month still quite mild, the last rains occur, while in November actually it's already winter, and nights become cold again.

Mexico City

When to go

The best time to visit Mexico City runs from November to April, being the dry season. Within this period, we can make some distinctions: in winter from November to February, and sometimes in March, cold nights are more frequent, with lows around freezing; from February to April it's the sunniest period, and daytime temperatures are a bit higher, especially in March and April. All in all the best months are March and April. Due to the remarkable temperature range between night and day, in the dry season it's better to dress in layers, with warm clothes for the evening, and light for the day. Also sunscreen, hat and sunglasses can be useful.
Even May and October can be taken into account: the rains are quite frequent, but less than at the height of the rainy season, and there is the advantage that nights are less cold.