How to get output of a column of a DataFrame? Suppose, I have a DataFrame DF which has columns: name, marks, phone in it.
How to het one of the column in python?
How to get output of a column of a DataFrame? Suppose, I have a DataFrame DF which has columns: name, marks, phone in it.
How to het one of the column in python?
You can get the output of any columns by:
For Name:
DF["name"]
or you can use:
DF.name
Like this, you can insert the name of any column in place of "name".
you can select one column, e.g. DF["name"]
or DF.name
and multiple columns by passing a list, e.g. DF[["name", "marks"]]
.
Be careful with the DF.name
notation as it doesn't work when the column name has special characters, e.g. whitespaces.