Mexico City, where it lies

In Mexico City, the huge federal capital of Mexico, the climate is subtropical, mild or pleasantly warm during the day, while nights are cool in summer and cold 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 a high altitude, which ranges between 2,200 and 2,600 meters (7,200 and 8,500 ft) in the different districts, so it's in the so-called tierras frìas ("Cold Lands").
Here are the average temperatures.
Mexico City - Average temperatures
Min (°C)6791112121212121087
Max (°C)212326272725232322222221
Min (°F)434548525454545454504645
Max (°F)707379818177737372727270

Rainfall is concentrated in the summer months: it exceeds 100 millimeters (4 inches) per month from June to September, and it is moderate in May and October, while it is 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 to get around. The dry season is long, and goes from November to April. Total rainfall is around 550/650 mm (21/25 in) per year in the eastern districts, while it increases in the western districts, up to 1,000 mm (40 in) per year in the Bosques de las Lomas, which are located at the foot of mountains that are more than 3,000 meters (9,800 ft) high and are able to enhance the summer rains.
Here is the average precipitation.
Mexico City - Average precipitation

In winter, from November to February, it is 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 neighbourhoods, the temperature can drop to freezing (0 °C or 32 °F). Already in February, the daytime temperature begins to rise, often exceeding 25 °C (77 °F). It hardly ever rains. Sometimes, there can be windy days, which have the merit 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 reaches 30 °C (86 °F); at night, however, it can still be a bit cold. In May, the first rains occur.

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 in comparison with the previous months: 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

The amount of sunshine in Mexico City is not very good, since the weather can be variable or cloudy even during the dry season of winter, however, it is 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, the tropical sun is very strong, also because the city is located at high altitudes, especially when it is highest above the horizon around noon, ie from April to August. Here are the average sunshine hours per day.
Mexico City - Sunshine

Best Time

The best time to visit Mexico City is the dry season, from November to April. 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. Owing 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. Sunscreen, a hat and sunglasses can be useful as well.
The months of May and October can be considered as an option as well: the rains are quite frequent, but less so than at the height of the rainy season, and there is the advantage that nights are not as cold as in winter.