Validating data types

A data type is a property of a variable that Python uses to understand how to store and manipulate data. For instance, a program needs to understand that variables storing 5 and 10 are numeric to be able to add them and get 15, or that the variables storing cat and hat are strings so that they could be concatenated (added) together to get cathat. Hence it becomes a preliminary and cardinal property of any pandas DataFrame.

A user-defined comparison function can be used to validate the data types of the test DataFrame:

Validating data types of test DataFrame

File1 and File2 correspond to the test and validation datasets respectively. It is evident from the output that all the data types of the test DataFrame match those of the validation DataFrame. If there is a mismatch, the output will display the number of columns that are inconsistent.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset