Tag: How To Get The DataTypes Of Columns Of A DataFrame?


  • How To Get The DataTypes Of Columns Of A DataFrame?

    How To Get The DataTypes Of Columns Of A DataFrame?

    How To Get The Data Types Of Columns Of A DataFrame? Table Of Contents: Syntax To Get The Data Types. Examples Of Getting Data Types. (1) Syntax pandas.DataFrame.dtypes pandas.DataFrame.dtypes.values Description: Return the dtypes of each columns of a DataFrame. (2) Examples Example-1 import pandas as pd student = {‘Name’:[‘Subrat’,’Abhispa’,’Arpita’,’Anuradha’,’Namita’], ‘Roll_No’:[100,101,102,103,104], ‘Subject’:[‘Math’,’English’,’Science’,’History’,’Commerce’], ‘Mark’:[95,88,76,73,93]} student_object = pd.DataFrame(student) student_object Output: student_object.dtypes Output: Name object Roll_No int64 Subject object Mark int64 dtype: object student_object.dtypes.values Output: array([dtype(‘O’), dtype(‘int64’), dtype(‘O’), dtype(‘int64’)], dtype=object) Example-2 import pandas as pd path = "E:BlogsPandasDocumentsMall_Customers.csv" customer_details = pd.read_csv(path) customer_details Output: customer_details.dtypes Output: CustomerID int64 Genre object Age int64 Annual_Income_(k$) int64 Spending_Score

    Read More