Let us see how to get the datatypes of columns in a Pandas DataFrame. TO get the datatypes, we will be using the
dtype() and the
Example 1 :
From the Output we can observe that on accessing or getting a single column separated from DataFrame its type gets converted to a Pandas Series type irrespective of the data type present in that series. On accessing the individual elements of the pandas Series we get the data is stored always in the form of
numpy.datatype() either numpy.int64 or
numpy.bool_ thus we observed that the Pandas data frame automatically typecast the data into the NumPy class format.
Example 2 :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course