Tag: How To Get The Columns Of A DataFrame?


  • How To Get The Columns Of A DataFrame?

    How To Get The Columns Of A DataFrame?

    How To Get The Columns Of A DataFrame? Table Of Contents: Syntax To Get The Column Names. Examples Of Fetching Column Names. (1) Syntax pandas.DataFrame.columns pandas.DataFrame.columns.values Description: It will fetch you the column names of the DataFrame. (2) Examples Of Columns : 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.columns Output: Index([‘Name’, ‘Roll_No’, ‘Subject’, ‘Mark’], dtype=’object’) Note: Here you can see that, columns will give you,  Index of Column names. Getting All The Column Values. student_object.column.values Output: array([‘Name’, ‘Roll_No’, ‘Subject’, ‘Mark’], dtype=object) Note: Here you can see that, columns.values  will give

    Read More