A transformer is a piece of equipment of great value in a public or private power substation in that it allows power to be supplied to the production processes. Thus, as it is used, the equipment is exposed to different environmental conditions such as level of contamination, salinity. , height, humidity, among others, as well as energy demand and quality, causing different types of electrical and thermal stress inside. That is why the objective of this study is to implement a programming code using the Duval method for the diagnosis of power transformers. For this, programming based on the supervised learning algorithm is used as a methodology to process the gas concentration levels contained in the dielectric oil obtained from the analysis of dissolved gases and for its interpretation the Duval method is used, which is presented in IEEE C57.104™-2019 standard. The designed code individually processes the dissolved gas analysis reports as well as large quantities of reports from the same transformer or from different ones, allowing the comparison of historical data of the equipment or equipment and the evaluation of its status according to the electrical stress to which it is subjected.